";
- echo "
$importstr $exportstr";
+ if (!empty($CFG->checklist_outcomes_input)){
+ $importoutcomesurl = new moodle_url('/mod/checklist/import_outcomes.php', array('id' => $this->cm->id));
+ $importoutcomesstr = get_string('import_outcomes', 'checklist');
+ $exportoutcomesurl = new moodle_url('/mod/checklist/select_export.php', array('id' => $this->cm->id));
+ $exportoutcomesstr = get_string('export_outcomes', 'checklist');
+ echo "
$importstr $importoutcomesstr $exportstr $exportoutcomesstr";
+ }
+ else{
+ echo "
$importstr $exportstr";
+ }
echo "
";
}
@@ -1925,7 +1957,7 @@ function process_view_actions() {
break;
default:
- error('Invalid action - "'.s($action).'"');
+ print_error(get_string('error_action', 'checklist', s($action))); // 'Invalid action - "{a}"'
}
if ($action != 'updatechecks') {
@@ -2028,7 +2060,7 @@ function process_edit_actions() {
$this->nextcolour($itemid);
break;
default:
- error('Invalid action - "'.s($action).'"');
+ print_error(get_string('error_action', 'checklist', s($action))); // 'Invalid action - "{a}"'
}
if ($additemafter) {
@@ -2086,7 +2118,7 @@ function process_report_actions() {
}
if (!confirm_sesskey()) {
- error('Invalid sesskey');
+ print_error('error_sesskey', 'checklist'); // 'Invalid sesskey';
}
switch ($action) {
@@ -2350,7 +2382,7 @@ function toggledisableitem($itemid) {
}
}
- function deleteitem($itemid, $forcedelete=false) {
+ function deleteitem($itemid, $forcedelete=false) {
global $DB;
if (isset($this->items[$itemid])) {
@@ -2372,6 +2404,19 @@ function deleteitem($itemid, $forcedelete=false) {
$DB->delete_records('checklist_item', array('id' => $itemid) );
$DB->delete_records('checklist_check', array('item' => $itemid) );
+ // Descriptions
+ $descriptions = $DB->get_records('checklist_description', array('itemid' => $itemid));
+ if ($descriptions) {
+ foreach($descriptions as $description){
+ if (!empty($description)){
+ // Documents
+ $DB->delete_records('checklist_document', array('descriptionid' => $description->id));
+ // Descriptions
+ $DB->delete_records('checklist_description', array('id' => $description->id));
+ }
+ }
+ }
+
$this->update_item_positions();
}
@@ -2927,7 +2972,7 @@ function update_all_autoupdate_checks() {
$check->teachertimestamp = 0;
$check->teachermark = CHECKLIST_TEACHERMARK_UNDECIDED;
- $check->id = $DB->insert_record('checklist_check', $check);
+ $check->id = $DB->insert_record('checklist_check', $check);
}
}
}
@@ -3162,8 +3207,774 @@ function get_user_groupings($userid, $courseid) {
}
return array();
}
+
+
+/**
+ * Extract skill repository and competency codes from a displaytext field
+ * outcome_name;outcome_shortname;outcome_description;scale_name;scale_items;scale_description
+ * "C2i2e-2011 A.1-1 :: Identifier les personnes ressources Tic et leurs rôles respectifs (...)";A.1-1;"Identifier les personnes ressources Tic et leurs rôles respectifs au niveau local, régional et national.";"Item référentiel";"Non pertinent,Non validé,Validé";"Ce barème est destiné à évaluer l'acquisition des compétences du module référentiel."
+ * | | | description
+ * | | ^ separator 2 '::'
+ * ^ separator 1 ' '
+ * | | competence_code
+ * | referentiel_code
+ * @imput displaytext string
+ * @output object
+ **/
+ function get_referentiel_code($displaytext){
+ // extract skill repository code and competency code from an outcome_name field
+ $item_outcome = new stdClass;
+ if (!empty($displaytext)){
+ if (preg_match('/(.*)::(.*)/i', trim($displaytext), $matches)){
+ if ($matches[1]){
+ if ($keywords = preg_split("/[\s]+/",$matches[1],-1,PREG_SPLIT_NO_EMPTY)){
+ if ($keywords[0] && $keywords[1]){
+ $item_outcome->code_referentiel=trim($keywords[0]);
+ $item_outcome->code_competence=trim($keywords[1]);
+ }
+ else{
+ return NULL;
+ }
+ }
+ }
+ }
+ }
+ return $item_outcome;
+ }
+
+/**
+ * Items selection for exporting outcomes
+ *
+ **/
+ function view_select_export() {
+ global $CFG, $OUTPUT;
+
+ if (!$this->canedit()) {
+ redirect(new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id)) );
+ }
+
+ if ((!$this->items) && $this->canedit()) {
+ redirect(new moodle_url('/mod/checklist/edit.php', array('id' => $this->cm->id)) );
+ }
+
+ // $currenttab = 'selectexport';
+ $currenttab = 'edit';
+
+ $this->view_header();
+
+ echo $OUTPUT->heading(format_string($this->checklist->name));
+
+ $this->view_tabs($currenttab);
+
+ add_to_log($this->course->id, 'checklist', 'view', "selectexport.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ $this->select_items();
+
+ $this->view_footer();
+ }
+
+ function select_items($viewother = false) {
+ global $DB, $OUTPUT, $PAGE;
+
+ echo '
+ * @package mod/checklist
+ */
+
+
+ function get_item_description($itemid, $userid){
+ //
+ global $DB;
+ return ($DB->select_record_sql("SELECT * FROM {checklist_description} WHERE itemid=? AND userid=?", array($itemid, $userid)));
+ }
+
+
+ function edit_description($itemid, $userid) {
+ global $DB;
+ global $CFG;
+ global $OUTPUT;
+ global $PAGE;
+
+ $description = NULL;
+ $document = NULL;
+
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ $thispage = new moodle_url('/mod/checklist/edit_description.php', array('id' => $this->cm->id) );
+ $returl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+
+ $currenttab = 'view';
+
+ add_to_log($this->course->id, 'checklist', 'view', "edit_description.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ if ($itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if (!empty($description)){
+ $documents = $DB->get_records('checklist_document', array("descriptionid" => $description->id));
+ }
+
+ $mform = new mod_checklist_description_form(null,
+ array('checklist'=>$this->checklist->id,
+ 'contextid'=>$context->id,
+ 'itemid'=>$itemid,
+ 'userid'=>$userid,
+ 'description'=>$description,
+ 'msg' => get_string('input_description', 'checklist')));
+
+ if ($mform->is_cancelled()) {
+ redirect($returnurl);
+ } else if ($mform->get_data()) {
+ checklist_set_description($mform, $this->checklist->id);
+ die();
+ }
+
+ $this->view_header();
+
+ echo ''.get_string('edit_description', 'checklist').'
'."\n";
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo format_text($this->checklist->intro, $this->checklist->introformat);
+ echo '
';
+
+ $mform->display();
+
+ echo $OUTPUT->box_end();
+ $this->view_footer();
+ }
+ }
+
+
+ function edit_upload_document($itemid, $userid, $descriptionid, $documentid=0) {
+ global $DB;
+ global $CFG;
+ global $OUTPUT;
+ global $PAGE;
+
+ $document=NULL;
+
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ $thispage = new moodle_url('/mod/checklist/edit_document.php', array('id' => $this->cm->id) );
+ $returl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+
+ $currenttab = 'view';
+
+ add_to_log($this->course->id, 'checklist', 'view', "edit_document.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ if (empty($descriptionid) && $itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if ($description){
+ $descriptionid=$description;
+ }
+ }
+
+ if ($descriptionid){
+ // Is there any document attached to that description
+ if ($documentid) {
+ $document = $DB->get_record('checklist_document', array("descriptionid" => $description->id, "id" => $documentid));
+ }
+ else{
+ // $documents = $DB->get_records('checklist_document', array("descriptionid" => $description->id));
+ $params=array("descriptionid" => $descriptionid);
+ $sql="SELECT * FROM {checklist_document} WHERE descriptionid=:descriptionid ORDER BY id DESC ";
+ $documents = $DB->get_records_sql($sql, $params);
+ if ($documents){
+ foreach($documents as $document){
+ break; // renvoyer le plus récent
+ }
+ }
+ }
+
+ $options = array('subdirs'=>0, 'maxbytes'=>get_max_upload_file_size($CFG->maxbytes, $this->course->maxbytes), 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
+
+ $mform = new mod_checklist_add_document_upload_form(null,
+ array('checklist'=>$this->checklist->id,
+ 'contextid'=>$context->id,
+ 'itemid'=>$itemid,
+ 'userid'=>$userid,
+ 'descriptionid'=>$descriptionid,
+ 'document'=>$document,
+ 'filearea'=>'document',
+ 'msg' => get_string('document_associe', 'checklist'),
+ 'options'=>$options));
+
+ if ($mform->is_cancelled()) {
+ redirect($returnurl);
+ } else if ($mform->get_data()) {
+ checklist_add_upload_document($mform, $this->checklist->id);
+ die();
+ // redirect(new moodle_url('/mod/checklist/view.php', array('id'=>$cm->id)));
+ }
+
+ $this->view_header();
+ echo ''.get_string('edit_document', 'checklist').'
'."\n";
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo format_text($this->checklist->intro, $this->checklist->introformat);
+ echo '
';
+
+ $mform->display();
+
+ echo $OUTPUT->box_end();
+ $this->view_footer();
+ }
+ }
+
+
+ function add_document($itemid, $userid, $descriptionid) {
+ global $DB;
+ global $CFG;
+ global $OUTPUT;
+ global $PAGE;
+
+ $document=NULL;
+
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ $thispage = new moodle_url('/mod/checklist/add_document.php', array('id' => $this->cm->id) );
+ $returl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+
+ $currenttab = 'view';
+
+ add_to_log($this->course->id, 'checklist', 'view', "add_document.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ if (empty($descriptionid) && $itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if ($description){
+ $descriptionid=$description;
+ }
+ }
+
+ if ($descriptionid){
+ $options = array('subdirs'=>0, 'maxbytes'=>get_max_upload_file_size($CFG->maxbytes, $this->course->maxbytes), 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
+
+ $mform = new mod_checklist_add_document_upload_form(null,
+ array('checklist'=>$this->checklist->id,
+ 'contextid'=>$context->id,
+ 'itemid'=>$itemid,
+ 'userid'=>$userid,
+ 'descriptionid'=>$descriptionid,
+ 'document'=>NULL,
+ 'filearea'=>'document',
+ 'msg' => get_string('document_associe', 'checklist'),
+ 'options'=>$options));
+
+ if ($mform->is_cancelled()) {
+ redirect($returnurl);
+ } else if ($mform->get_data()) {
+ checklist_add_upload_document($mform, $this->checklist->id);
+ die();
+ // redirect(new moodle_url('/mod/checklist/view.php', array('id'=>$cm->id)));
+ }
+
+ $this->view_header();
+ echo ''.get_string('edit_document', 'checklist').'
'."\n";
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo format_text($this->checklist->intro, $this->checklist->introformat);
+ echo '
';
+
+ $mform->display();
+
+ echo $OUTPUT->box_end();
+ $this->view_footer();
+ }
+ }
+
+
+
+ function edit_document($itemid, $userid, $document) {
+ global $DB;
+ global $CFG;
+ global $OUTPUT;
+ global $PAGE;
+
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ $thispage = new moodle_url('/mod/checklist/edit_document.php', array('id' => $this->cm->id) );
+ $returl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+
+ $currenttab = 'view';
+
+ add_to_log($this->course->id, 'checklist', 'view', "add_document.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ if ($document){
+ $options = array('subdirs'=>0, 'maxbytes'=>get_max_upload_file_size($CFG->maxbytes, $this->course->maxbytes), 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
+
+ $mform = new mod_checklist_update_document_upload_form(null,
+ array('checklist'=>$this->checklist->id,
+ 'contextid'=>$context->id,
+ 'itemid'=>$itemid,
+ 'userid'=>$userid,
+ 'descriptionid'=>$document->descriptionid,
+ 'document'=>$document,
+ 'filearea'=>'document',
+ 'msg' => get_string('document_associe', 'checklist'),
+ 'options'=>$options));
+
+
+
+ if ($mform->is_cancelled()) {
+ redirect($returnurl);
+ } else if ($mform->get_data()) {
+ checklist_update_upload_document($mform, $this->checklist->id);
+ die();
+ // redirect(new moodle_url('/mod/checklist/view.php', array('id'=>$cm->id)));
+ }
+
+ $this->view_header();
+ echo ''.get_string('edit_document', 'checklist').'
'."\n";
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo format_text($this->checklist->intro, $this->checklist->introformat);
+ echo '
';
+ $mform->display();
+ echo $OUTPUT->box_end();
+ $this->view_footer();
+ }
+ }
+
+
+
+ function delete_document($documentid) {
+ // $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ // $thispage = new moodle_url('/mod/checklist/delete_document.php', array('id' => $this->cm->id) );
+ $returnurl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+ add_to_log($this->course->id, 'checklist', 'view', "delete_document.php?id={$this->cm->id}&documentid=$documentid", $this->checklist->name, $this->cm->id);
+
+ if ($documentid){
+ $this->delete_document_record($documentid);
+ }
+ redirect($returnurl);
+ }
+
+
+ function delete_document_record($documentid) {
+ global $DB;
+ if ($documentid){
+ // get from table
+ if ($document=$DB->get_record('checklist_document', array("id" => $documentid))){
+ // delete file
+ // print_r($document);
+ if ($document->url_document){
+ checklist_delete_a_file($document->url_document);
+ }
+ // delete row entry
+ $DB->delete_records('checklist_document', array("id" => $documentid));
+ }
+ }
+ }
+
+ function delete_description($descriptionid) {
+ $returnurl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+ add_to_log($this->course->id, 'checklist', 'view', "delete_description.php?id={$this->cm->id}&descriptionid=$descriptionid", $this->checklist->name, $this->cm->id);
+
+ if ($descriptionid){
+ $this->delete_description_record($descriptionid);
+ }
+ redirect($returnurl);
+ }
+
+ function delete_description_record($descriptionid) {
+ global $DB;
+ if ($descriptionid){
+ // get from table
+ if ($description=$DB->get_record('checklist_description', array("id" => $descriptionid))){
+ // get all documents
+ if ($documents = $DB->get_records('checklist_document', array("descriptionid" => $description->id))){
+ foreach($documents as $document){
+ $this->delete_document_record($document->id);
+ }
+ }
+ // delete table checklist_description record
+ $DB->delete_records('checklist_description', array("id" => $description->id));
+ }
+ }
+ }
+
+ function display_description_documents($itemid, $userid, $edition=false){
+ // Display a description record and any document linked with it
+ global $DB;
+ global $OUTPUT;
+ global $CFG;
+
+ if ($itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if (!empty($description)){
+ echo '
';
+ if ($edition){
+ // icon edition
+ $editurl = new moodle_url('/mod/checklist/edit_description.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&itemid='.$itemid.'&userid='.$userid.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('edit_description','checklist').'"';
+ echo '
';
+ // icon delete
+ $editurl = new moodle_url('/mod/checklist/delete_description.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&descriptionid='.$description->id.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('delete_description','checklist').'"';
+ echo '
';
+ // icon edition link
+ $editurl = new moodle_url('/mod/checklist/add_document.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&itemid='.$itemid.'&userid='.$userid.'&descriptionid='.$description->id.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('add_link','checklist').'"';
+ echo '
';
+
+ if (!empty($CFG->enableportfolios)){
+ // portfolio upload link
+ $editurl = new moodle_url('/mod/checklist/mahara/upload_mahara.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&itemid='.$itemid.'&userid='.$userid.'&descriptionid='.$description->id.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('upload_portfolio','checklist').'"';
+ echo '
';
+ }
+
+ }
+ $documents = $DB->get_records('checklist_document', array("descriptionid" => $description->id));
+ if ($documents){
+ echo ''."\n";
+ foreach($documents as $document){
+ if ($document){
+ // Display link
+ $this->display_document($itemid, $userid, $document, $edition);
+ }
+ }
+ echo '
'."\n";
+ }
+
+ }
+ else{
+ if ($edition){
+ // icon edition
+ $editurl = new moodle_url('/mod/checklist/edit_description.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&itemid='.$itemid.'&userid='.$userid.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('edit_description','checklist').'"';
+ echo '
';
+ }
+ }
+ }
+ }
+
+ function display_description($description){
+ // Display a description record
+ if (!empty($description)){
+ echo stripslashes($description->description);
+ echo ' ['.userdate($description->timestamp).'] '."\n";
+ }
+ }
+
+ function display_document($itemid, $userid, $document, $edition=false){
+ // Display a document record
+ global $CFG;
+ global $OUTPUT;
+ if (!empty($document)){
+ if ($document->target==1){
+ $cible_document='_blank'; // fenêtre cible
+ }
+ else{
+ $cible_document='';
+ }
+ if ($document->title){
+ $etiquette_document=$document->title; // fenêtre cible
+ }
+ else{
+ $etiquette_document='';
+ }
+ echo ''.get_string('doc_num','checklist',$document->id).' '.$document->description_document."\n";
+ echo checklist_affiche_url($document->url_document, $etiquette_document, $cible_document);
+ echo ' ['.userdate($document->timestamp).'] '."\n";
+ if ($edition){
+ // icon edition
+ $editurl = new moodle_url('/mod/checklist/edit_document.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&itemid='.$itemid.'&userid='.$userid.'&documentid='.$document->id.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('edit_link','checklist').'"';
+ echo '
';
+ // icon delete
+ $editurl = new moodle_url('/mod/checklist/delete_document.php', array('id' => $this->cm->id) );
+ $baseurl = $editurl.'&documentid='.$document->id.'&sesskey='.sesskey();
+ echo ' ';
+ $title = '"'.get_string('delete_link','checklist').'"';
+ echo '
';
+ }
+ echo ''."\n";
+ }
+ }
+
+
+} // End of class
+
+// ################################ URL ###############################
+
+/**
+ * display an url accorging to moodle file management API
+ * @return string active link
+ * @ input $url : an uri
+ * @ input $etiquette : a label
+ * @ input $cible : a targeted frame
+*/
+function checklist_affiche_url($url, $etiquette="", $cible="") {
+ // MOODLE2 API
+ global $CFG;
+ // Moodle 1.9
+ /*
+ $importfile = "{$CFG->dataroot}/{$url}";
+ if (file_exists($importfile)) {
+ if ($CFG->slasharguments) {
+ $efile = "{$CFG->wwwroot}/file.php/$url";
+ }
+ else {
+ $efile = "{$CFG->wwwroot}/file.php?file=/$url";
+ }
+ }
+ else{
+ $efile = "$url";
+ }
+ */
+ // Moodle 2.0
+ if (!ereg("http",$url)){ // fichier telecharge
+ // l'URL a été correctement formée lors de la création du fichier
+ $efile = $CFG->wwwroot.'/pluginfile.php'.$url;
+ }
+ else{
+ $efile = $url;
+ }
+
+ if ($etiquette==""){
+ $l=strlen($url);
+ $posr=strrpos($url,'/');
+ if ($posr===false){ // no separator
+ $etiquette=$url;
+ }
+ else if ($posr==$l-1){ // ending separator
+ $etiquette=get_string("etiquette_inconnue", "checklist");
+ }
+ else if ($posr==0){ // heading and ending separator !
+ $etiquette=get_string("etiquette_inconnue", "checklist");
+ }
+ else {
+ $etiquette=substr($url,$posr+1);
+ }
+ }
+
+ if ($cible){
+ return "$etiquette";
+ }
+ else{
+ return "$etiquette";
+ }
+
}
+
function checklist_itemcompare($item1, $item2) {
if ($item1->position < $item2->position) {
return -1;
diff --git a/mod/checklist/mahara/locallib_portfolio.php b/mod/checklist/mahara/locallib_portfolio.php
new file mode 100644
index 00000000..29cfb9c2
--- /dev/null
+++ b/mod/checklist/mahara/locallib_portfolio.php
@@ -0,0 +1,426 @@
+.
+
+/**
+ * Library of functions for forum outside of the core api
+ */
+
+require_once($CFG->dirroot . '/mod/checklist/lib.php');
+require_once($CFG->dirroot . '/mod/checklist/locallib.php');
+require_once($CFG->libdir . '/portfolio/caller.php');
+require_once($CFG->libdir . '/filelib.php');
+
+
+/**
+ * @package mod-referentiel
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @copyright 2011 Jean Fruitet {@link http://univ-nantes.fr}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class checklist_portfolio_caller extends portfolio_module_caller_base {
+
+ protected $instanceid;
+ protected $export_format;
+
+ protected $cm;
+ protected $course;
+ protected $checklist;
+ protected $userid;
+
+ private $adresse_retour;
+
+ /**
+ * @return array
+ */
+ public static function expected_callbackargs() {
+ return array(
+ 'instanceid' => false,
+ 'userid' => false,
+ 'export_format' => false,
+ );
+ }
+ /**
+ * @param array $callbackargs
+ */
+ function __construct($callbackargs) {
+ parent::__construct($callbackargs);
+ if (!$this->instanceid) {
+ throw new portfolio_caller_exception('mustprovideinstanceid', 'checklist');
+ }
+ if (!$this->userid) {
+ throw new portfolio_caller_exception('mustprovideuser', 'checklist');
+ }
+ if (!isset($this->export_format)) {
+ throw new portfolio_caller_exception('mustprovideexportformat', 'checklist');
+ }
+ else{
+ // echo "
:: 86 ::$this->export_format\n";
+ if ($this->export_format!=PORTFOLIO_FORMAT_FILE) {
+ // depending on whether there are files or not, we might have to change richhtml/plainhtml
+ $this->supportedformats = array_merge(array($this->supportedformats), array(PORTFOLIO_FORMAT_RICH, PORTFOLIO_FORMAT_LEAP2A));
+ }
+ }
+ }
+ /**
+ * @global object
+ */
+ public function load_data() {
+ global $DB;
+ global $CFG;
+ if ($this->instanceid) {
+ if (!$this->checklist = $DB->get_record('checklist', array('id' => $this->instanceid))) {
+ throw new portfolio_caller_exception('invalidinstanceid', 'checklist');
+ }
+ }
+
+ if (!$this->cm = get_coursemodule_from_instance('checklist', $this->checklist->id)) {
+ throw new portfolio_caller_exception('invalidcoursemodule');
+ }
+ $this->adresse_retour= '/mod/checklist/view.php?id='.$this->cm->id;
+ }
+
+ /**
+ * @global object
+ * @return string
+ */
+ function get_return_url() {
+ global $CFG;
+ return $CFG->wwwroot . $this->adresse_retour;
+ }
+
+ /**
+ * @global object
+ * @return array
+ */
+ function get_navigation() {
+ global $CFG;
+
+ $navlinks = array();
+ $navlinks[] = array(
+ 'name' => format_string($this->checklist->name),
+ 'link' => $CFG->wwwroot . $this->adresse_retour,
+ 'type' => 'title'
+ );
+ return array($navlinks, $this->cm);
+ }
+
+ /**
+ * either a whole discussion
+ * a single post, with or without attachment
+ * or just an attachment with no post
+ *
+ * @global object
+ * @global object
+ * @uses PORTFOLIO_FORMAT_HTML
+ * @return mixed
+ */
+ function prepare_package() {
+ global $CFG;
+ global $OUTPUT;
+ global $USER;
+ // exporting a single HTML certificat
+ $content_to_export = $this->prepare_checklist();
+ $name = 'checklist'.'_'.$this->checklist->name.'_'.$this->checklist->id.'_'.$this->userid.'.html';
+ // $manifest = ($this->exporter->get('format') instanceof PORTFOLIO_FORMAT_PLAINHTML);
+ $manifest = ($this->exporter->get('format') instanceof PORTFOLIO_FORMAT_RICH);
+
+ // DEBUG
+ /*
+ echo "
DEBUG :: 179 :: CONTENT
\n";
+ echo($content_to_export);
+ echo "
MANIFEST : $manifest
\n";
+ echo "
FORMAT ".$this->exporter->get('formatclass')."\n";
+ */
+
+ $content=$content_to_export;
+
+ if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
+ $leapwriter = $this->exporter->get('format')->leap2a_writer($USER);
+ // DEBUG
+ //echo "
DEBUG :: 169 :: LEAPWRITER
\n";
+ //print_object($leapwriter);
+ // exit;
+ if ($leapwriter){
+ if ($this->prepare_certificat_leap2a($leapwriter, $content_to_export)){
+ // echo "
DEBUG :: 175\n";
+ $content = $leapwriter->to_xml();
+ // DEBUG
+ // echo "
DEBUG :: mod/checklist/mahara/locallib_portfolio.php :: 167
\n";
+ // echo htmlspecialchars($content);
+ $name = $this->exporter->get('format')->manifest_name();
+ }
+ }
+ }
+ /*
+ // DEBUG
+ echo "
DEBUG :: 176
\n";
+ print_object($content);
+ */
+ $this->get('exporter')->write_new_file($content, $name, $manifest);
+
+ }
+
+
+
+ /**
+ * @return string
+ */
+ function get_sha1() {
+ $filesha = '';
+ try {
+ $filesha = $this->get_sha1_file();
+ } catch (portfolio_caller_exception $e) { } // no files
+
+ if ($this->checklist && $this->userid){
+ return sha1($filesha . ',' . $this->checklist->id. ',' . $this->checklist->name. ',' . $this->userid);
+ }
+ return 0;
+ }
+
+ function expected_time() {
+ // a file based export
+ if ($this->singlefile) {
+ return portfolio_expected_time_file($this->singlefile);
+ }
+ else{
+ return PORTFOLIO_TIME_LOW;
+ }
+ }
+
+ /**
+ * @uses CONTEXT_MODULE
+ * @return bool
+ */
+ function check_permissions() {
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ return true;
+ }
+
+ /**
+ * @return string
+ */
+ public static function display_name() {
+ return get_string('modulename', 'checklist');
+ }
+
+ public static function base_supported_formats() {
+ //return array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_LEAP2A);
+ return array(PORTFOLIO_FORMAT_FILE);
+ }
+
+ /**
+ * helper function to add a leap2a entry element
+ * that corresponds to a single certificate,
+ *
+ * the entry/ies are added directly to the leapwriter, which is passed by ref
+ *
+ * @global object $checklist $userid the stdclass object representing the database record
+ * @param portfolio_format_leap2a_writer $leapwriter writer object to add entries to
+ * @param string $content the content of the certificate (prepared by {@link prepare_checklist}
+ *
+ * @return int id of new entry
+ */
+ private function prepare_certificat_leap2a(portfolio_format_leap2a_writer $leapwriter, $content) {
+ global $USER;
+ $order = array( " ", "\r\n", "\n", "\r");
+ $replace = ' ';
+ $content=str_replace($order, $replace, $content);
+
+ $title=get_string('modulename', 'checklist').' '.$this->checklist->name. ' '. $this->userid;
+ $entry = new portfolio_format_leap2a_entry('checklist_id' . $this->checklist->id .'_user'. $this->userid, $title, 'leap2', $content); // proposer ability ?
+ $entry->published = time();
+ $entry->updated = time();
+ $entry->author->id = $this->userid;
+ $entry->summary = $this->checklist->name.' '.strip_tags($this->checklist->intro);
+ $entry->add_category('web', 'any_type', 'CheckList');
+ // DEBUG
+ /*
+ echo "
246 :: ENTRY
\n";
+ print_object($entry);
+ */
+ $leapwriter->add_entry($entry);
+ /*
+ echo "
286 :: LEAPWRITER
\n";
+ print_object($leapwriter);
+ */
+ return $entry->id;
+ }
+
+ /**
+ * this is a very cut down version of what is in checklist_certificat print_lib
+ *
+ * @global object
+ * @return string
+ */
+ private function prepare_checklist() {
+ global $DB;
+ $output='';
+ $info_checklist='';
+ $info_items='';
+ $fullname ='';
+ $login='';
+
+ if(!empty($this->userid)){
+ $user= $DB->get_record('user', array('id' => $this->userid));
+ if ($user){
+ $fullname = fullname($user, true);
+ $login=$user->username;
+ }
+ }
+
+ if (!empty($this->checklist) && !empty($this->userid) ) {
+ $info_checklist = "".$this->checklist->name."
\n".strip_tags($this->checklist->intro)."\n";
+ if (!empty($this->checklist->timecreated)){
+ $info_checklist .= "
".get_string('timecreated', 'checklist')." ".userdate($this->checklist->timecreated)." ";
+ }
+ if (!empty($this->checklist->timemodified)){
+ $info_checklist .= "
".get_string('timemodified', 'checklist')." ".userdate($this->checklist->timemodified)." ";
+ }
+ $info_checklist .= "
\n";
+
+ $info_items='';
+ $items=$DB->get_records('checklist_item', array('checklist' => $this->checklist->id), 'position ASC', '*');
+ if ($items){
+ $info_items.= "".get_string('items', 'checklist')."
\n";
+ $info_items.= "\n";
+ foreach ($items as $item){
+ if ($item){
+ $info_items.="- ".get_string('id', 'checklist').$item->id." ".stripslashes($item->displaytext)."\n";
+
+ // checks
+ $checks=$DB->get_records('checklist_check', array('item' => $item->id, 'userid' => $this->userid));
+ if ($checks){
+ foreach ($checks as $check){
+ switch ($check->teachermark) {
+ case CHECKLIST_TEACHERMARK_YES:
+ $info_items.="
".get_string('teachermarkyes','checklist');
+ break;
+ case CHECKLIST_TEACHERMARK_NO:
+ $info_items.="
".get_string('teachermarkno','checklist');
+ break;
+ default:
+ $info_items.="
".get_string('teachermarkundecided','checklist');
+ break;
+ }
+
+ if (!empty($check->usertimestamp)){
+ $info_items.= " (".get_string('usertimestamp', 'checklist')." ".userdate($check->usertimestamp).") ";
+ }
+ if (!empty($check->teachertimestamp)){
+ $info_items.= " (".get_string('teachertimestamp', 'checklist')." ".userdate($check->teachertimestamp).") ";
+ }
+ $info_items.= "
\n";
+ }
+ }
+
+ // comments
+ $comments=$DB->get_records('checklist_comment', array('itemid' => $item->id, 'userid' => $this->userid));
+ if ($comments){
+ $info_items.= "".get_string('comments', 'checklist')."
\n";
+ foreach ($comments as $comment){
+ if (!empty($comment->text)){
+ $info_items.= "
". stripslashes($comment->text)." ";
+ }
+ if ($comment->commentby){
+ $teacher= $DB->get_record('user', array('id' => $comment->commentby));
+ if ($teacher){
+ $fullnameteacher =fullname($teacher, true);
+ }
+ }
+ if (!empty($fullnameteacher)){
+ $info_items.="
(".get_string('commentby', 'checklist')." ".$fullnameteacher.") ";
+ }
+ $info_items.= "\n";
+ }
+ }
+ // description
+ $descriptions=$DB->get_records('checklist_description', array('itemid' => $item->id, 'userid' => $this->userid));
+ if ($descriptions){
+ $info_items.= "".get_string('argumentation', 'checklist')."
\n";
+
+ foreach ($descriptions as $description){
+ if (!empty($description->description)){
+ $info_items.= "".stripslashes($description->description)." ";
+ }
+ if (!empty($description->timestamp)){
+ $info_items.= " (".userdate($description->timestamp).") \n";
+ }
+ // documents
+ $documents=$DB->get_records('checklist_document', array('descriptionid' => $description->id));
+ if ($documents){
+ $info_items.= "
\n";
+ foreach ($documents as $document){
+ if (!empty($document)){
+ if ($document->target==1){
+ $cible_document='_blank'; // fenêtre cible
+ }
+ else{
+ $cible_document='';
+ }
+ if ($document->title){
+ $etiquette_document=$document->title; // fenêtre cible
+ }
+ else{
+ $etiquette_document='';
+ }
+ $info_items.="- ".get_string('doc_num','checklist',$document->id).' '.stripslashes($document->description_document)." ";
+ $info_items.=checklist_affiche_url($document->url_document, $etiquette_document, $cible_document);
+ $info_items.=' ['.userdate($document->timestamp).'] '."
\n";
+ }
+ }
+ $info_items.= "
\n";
+ }
+ $info_items.= "\n";
+ }
+
+ }
+ $info_items.= " \n";
+ }
+ }
+ $info_items.= "
\n";
+ }
+ // format the body
+ $s=''.get_string('modulename','checklist').'
'."\n";
+ $s.=''.$fullname.' ('.$login.')
';
+ $s.=$info_checklist;
+ $s.=$info_items;
+
+ // DEBUG
+ // echo $s;
+ // exit;
+ $options = portfolio_format_text_options();
+ $format = $this->get('exporter')->get('format');
+ $formattedtext = format_text($s, FORMAT_HTML, $options);
+
+ // $formattedtext = portfolio_rewrite_pluginfile_urls($formattedtext, $this->context->id, 'mod_checklist', 'document', $item->id, $format);
+
+ $output = '';
+ $output .= '| ';
+ $output .= ' '.get_string('modulename', 'checklist').' '. format_string($this->checklist->name).' ';
+ $output .= ' |
';
+ $output .= '| ';
+ $output .= $formattedtext;
+ $output .= ' |
'."\n\n";
+
+ }
+ return $output;
+ }
+
+
+
+}
+
diff --git a/mod/checklist/mahara/mahara.php b/mod/checklist/mahara/mahara.php
new file mode 100644
index 00000000..8d306c66
--- /dev/null
+++ b/mod/checklist/mahara/mahara.php
@@ -0,0 +1,472 @@
+libdir.'/formslib.php');
+
+
+/**
+ * @package mod-checklist
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class mod_checklist_mahara_upload_form extends moodleform {
+ function definition() {
+ global $CFG, $COURSE, $DB;
+
+ $mform = & $this->_form;
+ $instance = $this->_customdata;
+ // print_object($instance);
+ // exit;
+ // visible elements
+ $mform->addElement('header', 'general', $instance['msg']);
+ $mform->addHelpButton('general', 'documenth','checklist');
+
+
+ // Get Mahara hosts we are doing SSO with
+ $sql = "
+ SELECT DISTINCT
+ h.id,
+ h.name
+ FROM
+ {mnet_host} h,
+ {mnet_application} a,
+ {mnet_host2service} h2s_IDP,
+ {mnet_service} s_IDP,
+ {mnet_host2service} h2s_SP,
+ {mnet_service} s_SP
+ WHERE
+ h.id != :mnet_localhost_id AND
+ h.id = h2s_IDP.hostid AND
+ h.deleted = 0 AND
+ h.applicationid = a.id AND
+ h2s_IDP.serviceid = s_IDP.id AND
+ s_IDP.name = 'sso_idp' AND
+ h2s_IDP.publish = '1' AND
+ h.id = h2s_SP.hostid AND
+ h2s_SP.serviceid = s_SP.id AND
+ s_SP.name = 'sso_idp' AND
+ h2s_SP.publish = '1' AND
+ a.name = 'mahara'
+ ORDER BY
+ h.name";
+
+ if ($hosts = $DB->get_records_sql($sql, array('mnet_localhost_id'=>$CFG->mnet_localhost_id))) {
+ foreach ($hosts as &$h) {
+ $h = $h->name;
+ }
+ $mform->addElement('select', 'hostid', get_string("site"), $hosts);
+ $mform->addHelpButton('hostid', 'site', 'checklist');
+ $mform->setDefault('hostid', key($hosts));
+ }
+ else {
+ // TODO: Should probably error out if no mahara hosts found?
+ $mform->addElement('static', '', '', get_string('nomaharahostsfound', 'checklist'));
+ }
+
+ $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+
+ // hidden params
+
+ $mform->addElement('hidden', 'checklist', $instance['checklist']);
+ $mform->setType('checklist', PARAM_INT);
+
+
+ $mform->addElement('hidden', 'descriptionid');
+ $mform->setType('descriptionid', PARAM_INT);
+ if ($instance['descriptionid']){
+ $mform->setDefault('descriptionid', $instance['descriptionid']);
+ }
+
+ $mform->addElement('hidden', 'contextid', $instance['contextid']);
+ $mform->setType('contextid', PARAM_INT);
+
+ $mform->addElement('hidden', 'itemid', $instance['itemid']);
+ $mform->setType('itemid', PARAM_INT);
+
+ $mform->addElement('hidden', 'userid', $instance['userid']);
+ $mform->setType('userid', PARAM_INT);
+
+ $mform->addElement('hidden', 'action', 'uploadfile');
+ $mform->setType('action', PARAM_ALPHA);
+
+ // buttons
+ $this->add_action_buttons(true, get_string('savechanges', 'admin'));
+
+ }
+}
+
+
+/**
+ * checklist class for mahara portfolio
+ *
+ */
+class checklist_mahara_class extends checklist_class {
+
+ private $remotehost;
+ private $remotehostid;
+
+ function checklist_mahara_class($cmid='staticonly', $userid=0, $checklist=NULL, $cm=NULL, $course=NULL) {
+ parent::checklist_class($cmid, $userid, $checklist, $cm, $course);
+ }
+
+ /* ****************
+ function view() {
+ global $CFG, $OUTPUT;
+
+ if ((!$this->items) && $this->canedit()) {
+ redirect(new moodle_url('/mod/checklist/edit.php', array('id' => $this->cm->id)) );
+ }
+
+ $currenttab = 'view';
+
+ $this->view_header();
+
+ echo $OUTPUT->heading(format_string($this->checklist->name));
+
+ $this->view_tabs($currenttab);
+
+ add_to_log($this->course->id, 'checklist', 'view', "view.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ // Mahara && Portofolio stuff
+ if (empty($CFG->enableportfolios)){
+ redirect(new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id)) );
+ }
+ else{
+ // DEBUG
+ // echo "
DEBUG :: assigment/type/mahara/assigment.class.php :: 75\n";
+
+ $query = optional_param('q', null, PARAM_TEXT);
+ // echo "
QUERY : $query\n";
+
+ list($error, $views) = $this->get_views($query);
+
+ // DEBUG
+ // echo "
DEBUG :: assigment/type/mahara/assigment.class.php :: 83
ERROR
\n";
+ // print_object($error);
+ // echo "
VIEWS\n";
+ // print_object($views);
+ // echo "
\n";
+ // exit;
+
+ if ($error) {
+ echo $error;
+ } else {
+ $this->remotehost = $DB->get_record('mnet_host', array('id'=>$this->remote_mnet_host_id()));
+ $this->remotehost->jumpurl = $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . $this->remotehost->id;
+ echo '';
+ if ($views['count'] < 1) {
+ if ($query){
+ echo get_string('noviewsfound', 'checklist', $this->remotehost->name);
+ } else {
+ echo get_string('noviewscreated', 'checklist', $this->remotehost->name);
+ }
+ } else {
+ echo '' . $this->remotehost->name . ': ' . get_string('viewsby', 'checklist', $views['displayname']) . '
';
+ echo '';
+ }
+ }
+ }
+
+
+ $this->view_footer();
+ }
+ ***************/
+
+ function add_mahara_document($itemid, $userid, $descriptionid, $hostid=0, $viewid=0) {
+ global $DB;
+ global $CFG;
+ global $OUTPUT;
+ global $PAGE;
+
+ $document=NULL;
+
+ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+
+ $thispage = new moodle_url('/mod/checklist/mahara/upload_mahara.php', array('id' => $this->cm->id) );
+ $returnurl = new moodle_url('/mod/checklist/view.php', array('id' => $this->cm->id));
+
+ $currenttab = 'view';
+
+ add_to_log($this->course->id, 'checklist', 'view', "upload_mahara.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id);
+
+ // Mahara && Portofolio stuff
+ if (empty($CFG->enableportfolios)){
+ redirect($returnurl);
+ }
+
+ if (empty($descriptionid) && $itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if ($description){
+ $descriptionid=$description;
+ }
+ }
+
+ if ($descriptionid){
+ if (!empty($hostid) && !empty($viewid)) {
+ $this->set_remote_mnet_host_id($hostid);
+ if ($this->submit_view($descriptionid, $hostid, $viewid)) {
+
+ //TODO fix log actions - needs db upgrade
+ //redirect
+ redirect($returnurl);
+ }
+ }
+ else{
+
+ $options = array();
+
+ $mform = new mod_checklist_mahara_upload_form(null,
+ array('checklist'=>$this->checklist->id,
+ 'contextid'=>$context->id,
+ 'itemid'=>$itemid,
+ 'userid'=>$userid,
+ 'descriptionid'=>$descriptionid,
+ 'msg' => get_string('typemahara', 'checklist'),
+ 'options'=>$options));
+
+ if ($mform->is_cancelled()) {
+ redirect($returnurl);
+ } else if ($mform->get_data()) {
+ $this->upload($mform, $this->checklist->id);
+ die();
+ //redirect(new moodle_url('/mod/checklist/view.php', array('id'=>$cm->id)));
+ }
+ }
+ $this->view_header();
+ echo ''.get_string('edit_document', 'checklist').'
'."\n";
+ echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
+ echo format_text($this->checklist->intro, $this->checklist->introformat);
+ echo '
';
+
+ $mform->display();
+
+ echo $OUTPUT->box_end();
+ $this->view_footer();
+ }
+ }
+
+
+ function upload($mform, $checklistid) {
+ // Document creation form
+ // checklist_document update
+ // sets checklist_document table
+ global $CFG, $USER, $DB, $OUTPUT;
+
+ $currenttab = 'view';
+ $viewurl=new moodle_url('/mod/checklist/view.php', array('checklist'=>$checklistid));
+
+ if ($formdata = $mform->get_data()) {
+ // DEBUG
+ // print_object($formdata);
+ // exit;
+ if (!empty($formdata->descriptionid)) {
+
+ if (!empty($formdata->hostid)) {
+ $this->set_remote_mnet_host_id($formdata->hostid);
+
+ $this->view_header();
+ echo $OUTPUT->heading(format_string($this->checklist->name));
+ $this->view_tabs($currenttab);
+
+ // DEBUG
+ // echo "
DEBUG :: assigment/type/mahara/assigment.class.php :: 75\n";
+
+ $query = optional_param('q', null, PARAM_TEXT);
+ // echo "
QUERY : $query\n";
+
+ list($error, $views) = $this->get_views($query);
+
+ // DEBUG
+ // echo "
DEBUG :: assigment/type/mahara/assigment.class.php :: 83
ERROR
\n";
+ // print_object($error);
+ // echo "
VIEWS\n";
+ // print_object($views);
+ // echo "
\n";
+ // exit;
+
+ if ($error) {
+ echo $error;
+ }
+ else {
+ $this->remotehost = $DB->get_record('mnet_host', array('id'=>$this->remote_mnet_host_id()));
+ $this->remotehost->jumpurl = $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . $this->remotehost->id;
+ echo '';
+ if ($views['count'] < 1) {
+ if ($query){
+ echo get_string('noviewsfound', 'checklist', $this->remotehost->name);
+ } else {
+ echo get_string('noviewscreated', 'checklist', $this->remotehost->name);
+ }
+ } else {
+ echo '' . $this->remotehost->name . ': ' . get_string('viewsby', 'checklist', $views['displayname']) . '
';
+ echo '';
+ }
+ }
+ $this->view_footer();
+ }
+ }
+ }
+ }
+
+
+
+
+ function set_remote_mnet_host_id($var) {
+ $this->remotehostid=$var;
+ }
+
+ function remote_mnet_host_id() {
+ return $this->remotehostid;
+ }
+
+ function get_mnet_sp() {
+ global $CFG, $MNET;
+ require_once $CFG->dirroot . '/mnet/peer.php';
+ $mnet_sp = new mnet_peer();
+ $mnet_sp->set_id($this->remote_mnet_host_id());
+ return $mnet_sp;
+ }
+
+ function submit_view($descriptionid, $hostid, $viewid) {
+ global $CFG, $USER, $MNET, $DB;
+
+ require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
+ $mnet_sp = $this->get_mnet_sp();
+ $mnetrequest = new mnet_xmlrpc_client();
+ $mnetrequest->set_method('mod/mahara/rpclib.php/submit_view_for_assessment');
+ $mnetrequest->add_param($USER->username);
+ $mnetrequest->add_param($viewid);
+
+ if ($mnetrequest->send($mnet_sp) !== true) {
+ return false;
+ }
+ $data = $mnetrequest->response;
+
+ // DEBUG
+ //echo "
DEBUG :: ./mod/checklist/mahara/mahara.php :: 378 :: DATA
\n";
+ //print_object($data);
+ //echo "
\n";
+
+
+/****************
+ $rawoutcomes = isset($data['outcome']) ? $data['outcome'] : array();
+
+ $mahara_outcomes = array();
+
+ foreach ($rawoutcomes as &$o) {
+ $scale1 = array();
+ foreach ($o['scale'] as &$item) {
+ $scale1[$item['value']] = $item['name'];
+ }
+ $mahara_outcomes[$o['outcome']][] = array('scale' => $scale1, 'grade' => $o['grade']);
+ }
+
+ unset($data['outcome']);
+ unset($rawoutcomes);
+*************************/
+
+ $document = new object();
+ $document->descriptionid=$descriptionid;
+ $document->description_document=get_string('viewmahara','checklist');
+ // $document->url_document="http://localhost/moodle2/auth/mnet/jump.php?hostid=".$hostid."&wantsurl=".urlencode($data['url']);
+ $document->url_document=$CFG->wwwroot ."/auth/mnet/jump.php?hostid=".$hostid."&wantsurl=".urlencode($data['url']);
+
+ $document->title=clean_text($data['title']);
+ $document->target=1;
+ $document->timestamp=time();
+ // document
+ if ($newdocid=$DB->insert_record("checklist_document", $document)){
+ // DEBUG
+ $document->id=$newdocid;
+ }
+ //print_object($document);
+ //echo "
EXIT :: 410\n";
+ //exit;
+
+
+ // Release Mahara page
+ // We don't lock the page ; that's not an assigment stuff
+ $mnet_sp = $this->get_mnet_sp();
+ $mnetrequest = new mnet_xmlrpc_client();
+ $mnetrequest->set_method('mod/mahara/rpclib.php/release_submitted_view');
+ $mnetrequest->add_param($data['id']);
+ $mnetrequest->add_param($viewid);
+ $mnetrequest->add_param($USER->username);
+ // Do something if this fails? Or use cron to export the same data later?
+ if ($mnetrequest->send($mnet_sp) === false) {
+ $error = "RPC mod/mahara/rpclib.php/release_submitted_view:
";
+ foreach ($mnetrequest->error as $errormessage) {
+ list($code, $errormessage) = array_map('trim',explode(':', $errormessage, 2));
+ $error .= "ERROR $code:
$errormessage
";
+ }
+ }
+
+ return $newdocid;
+ }
+
+ function get_views($query) {
+ global $CFG, $USER, $MNET;
+
+ $error = false;
+ $viewdata = array();
+ if (!is_enabled_auth('mnet')) {
+ $error = get_string('authmnetdisabled', 'mnet');
+ } else if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
+ $error = get_string('notpermittedtojump', 'mnet');
+ } else {
+ // set up the RPC request
+ require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
+ $mnet_sp = $this->get_mnet_sp();
+ $mnetrequest = new mnet_xmlrpc_client();
+ $mnetrequest->set_method('mod/mahara/rpclib.php/get_views_for_user');
+ $mnetrequest->add_param($USER->username);
+ $mnetrequest->add_param($query);
+
+ if ($mnetrequest->send($mnet_sp) === true) {
+ $viewdata = $mnetrequest->response;
+ } else {
+ $error = "RPC mod/mahara/rpclib.php/get_views_for_user:
";
+ foreach ($mnetrequest->error as $errormessage) {
+ list($code, $errormessage) = array_map('trim',explode(':', $errormessage, 2));
+ $error .= "ERROR $code:
$errormessage
";
+ }
+ }
+ }
+ return array($error, $viewdata);
+ }
+
+
+}
diff --git a/mod/checklist/mahara/upload_mahara.php b/mod/checklist/mahara/upload_mahara.php
new file mode 100644
index 00000000..487d3614
--- /dev/null
+++ b/mod/checklist/mahara/upload_mahara.php
@@ -0,0 +1,116 @@
+.
+
+/**
+ * Add a new document to a description
+ * @author David Smith
+ * @author Jean Fruitet
+ * @package mod/checklist
+ */
+
+
+require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
+require_once(dirname(dirname(__FILE__)).'/lib.php');
+require_once(dirname(dirname(__FILE__)).'/locallib.php');
+
+require_once(dirname(__FILE__).'/mahara.php'); // mahara class
+require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/repository/lib.php'); // Repository API
+
+global $DB;
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$checklistid = optional_param('checklist', 0, PARAM_INT); // checklist instance ID
+$itemid = optional_param('itemid', 0, PARAM_INT); // Item ID
+$userid = optional_param('userid', 0, PARAM_INT); // userID
+$descriptionid = optional_param('descriptionid', 0, PARAM_INT); // description ID
+$cancel = optional_param('cancel', 0, PARAM_BOOL);
+
+// POUR MAHARA
+$hostid = optional_param('hostid', 0, PARAM_INT); // le nouveau document recupérer sur Mahara
+$view = optional_param('view', 0, PARAM_INT); // le nouveau document recupérer sur Mahara
+
+$url = new moodle_url('/mod/checklist/mahara/upload_mahara.php');
+if ($id) {
+ if (!$cm = get_coursemodule_from_id('checklist', $id)){
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
+ $url->param('id', $id);
+} else if ($checklistid) {
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $url->param('checklist', $checklistid);
+} else {
+ print_error('error_specif_id', 'checklist'); // 'You must specify a course_module ID or an instance ID'
+}
+
+
+// Description ?
+if (!$descriptionid && $itemid && $userid) {
+ $description = $DB->get_record('checklist_description', array("itemid"=>$itemid, "userid"=>$userid));
+ if (!empty($description)){
+ $descriptionid=$description->id;
+ }
+}
+
+$PAGE->set_url($url);
+$returnurl=new moodle_url('/mod/checklist/view.php?checklist='.$checklist->id);
+
+require_login($course, true, $cm);
+
+$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+if (empty($userid)){
+ if (has_capability('mod/checklist:updateown', $context)) {
+ $userid = $USER->id;
+ }
+}
+
+
+/// If it's hidden then it's don't show anything. :)
+/// Some capability checks.
+if (empty($cm->visible)
+ && (
+ !has_capability('moodle/course:viewhiddenactivities', $context)
+ &&
+ !has_capability('mod/checklist:updateown', $context)
+ )
+
+ ) {
+ print_error('activityiscurrentlyhidden','error',$returnurl);
+}
+
+
+if ($cancel) {
+ if (!empty($SESSION->returnpage)) {
+ $return = $SESSION->returnpage;
+ unset($SESSION->returnpage);
+ redirect($return);
+ } else {
+ redirect($returnurl);
+ }
+}
+
+
+if ($chk = new checklist_mahara_class($cm->id, 0, $checklist, $cm, $course)) {
+ $chk->add_mahara_document($itemid, $userid, $descriptionid, $hostid, $view);
+}
+
diff --git a/mod/checklist/pix/edit.gif b/mod/checklist/pix/edit.gif
new file mode 100644
index 00000000..80d3344a
Binary files /dev/null and b/mod/checklist/pix/edit.gif differ
diff --git a/mod/checklist/pix/link.png b/mod/checklist/pix/link.png
new file mode 100644
index 00000000..85e53886
Binary files /dev/null and b/mod/checklist/pix/link.png differ
diff --git a/mod/checklist/pix/upload_portfolio.png b/mod/checklist/pix/upload_portfolio.png
new file mode 100644
index 00000000..3797f64b
Binary files /dev/null and b/mod/checklist/pix/upload_portfolio.png differ
diff --git a/mod/checklist/report.php b/mod/checklist/report.php
index d461574c..a2dd6b48 100644
--- a/mod/checklist/report.php
+++ b/mod/checklist/report.php
@@ -35,30 +35,18 @@
$url = new moodle_url('/mod/checklist/report.php');
if ($id) {
if (! $cm = get_coursemodule_from_id('checklist', $id)) {
- error('Course Module ID was incorrect');
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
-
- if (! $course = $DB->get_record('course', array('id' => $cm->course) )) {
- error('Course is misconfigured');
- }
-
- if (! $checklist = $DB->get_record('checklist', array('id' => $cm->instance) )) {
- error('Course module is incorrect');
- }
-
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
$url->param('id', $id);
} else if ($checklistid) {
- if (! $checklist = $DB->get_record('checklist', array('id' => $checklistid) )) {
- error('Course module is incorrect');
- }
- if (! $course = $DB->get_record('course', array('id' => $checklist->course) )) {
- error('Course is misconfigured');
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
- if (! $cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
- error('Course Module ID was incorrect');
- }
-
$url->param('checklist', $checklistid);
} else {
diff --git a/mod/checklist/select_export.php b/mod/checklist/select_export.php
new file mode 100644
index 00000000..cbc38c23
--- /dev/null
+++ b/mod/checklist/select_export.php
@@ -0,0 +1,71 @@
+.
+
+/**
+ * This page prints a particular instance of checklist
+ *
+ * @author David Smith
+ * @author Jean Fruitet
+ * @package mod/checklist
+ */
+
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+require_once(dirname(__FILE__).'/locallib.php');
+
+global $DB;
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$checklistid = optional_param('checklist', 0, PARAM_INT); // checklist instance ID
+
+$url = new moodle_url('/mod/checklist/view.php');
+if ($id) {
+ if (!$cm = get_coursemodule_from_id('checklist', $id)){
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
+ $url->param('id', $id);
+} else if ($checklistid) {
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $url->param('checklist', $checklistid);
+} else {
+ print_error('error_specif_id', 'checklist'); // 'You must specify a course_module ID or an instance ID'
+}
+
+$PAGE->set_url($url);
+$PAGE->requires->js('/mod/checklist/functions.js');
+require_login($course, true, $cm);
+
+if ($CFG->version < 2011120100) {
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+} else {
+ $context = context_module::instance($cm->id);
+}
+$userid = 0;
+if (has_capability('mod/checklist:updateown', $context)) {
+ $userid = $USER->id;
+}
+
+$chk = new checklist_class($cm->id, $userid, $checklist, $cm, $course);
+
+$chk->view_select_export();
diff --git a/mod/checklist/settings.php b/mod/checklist/settings.php
new file mode 100644
index 00000000..c936b720
--- /dev/null
+++ b/mod/checklist/settings.php
@@ -0,0 +1,36 @@
+fulltree) {
+
+
+$options = array();
+
+
+// user can add description and documents
+$options[0] = 0;
+$options[1] = 1;
+if (isset($CFG->checklist_description_display)){
+ $settings->add(new admin_setting_configselect('checklist_description_display', get_string('checklist_description', 'checklist'),
+ get_string('config_description', 'checklist'), $CFG->checklist_description_display, $options));
+}
+else{
+ $settings->add(new admin_setting_configselect('checklist_description_display', get_string('checklist_description', 'checklist'),
+ get_string('config_description', 'checklist'), 1, $options));
+}
+
+// user can import or export outcomes files as item list
+unset($options);
+$options[0] = 0;
+$options[1] = 1;
+if (isset($CFG->checklist_outcomes_input)){
+ $settings->add(new admin_setting_configselect('checklist_outcomes_input', get_string('outcomes_input', 'checklist'),
+ get_string('config_outcomes_input', 'checklist'), $CFG->checklist_outcomes_input, $options));
+}
+else{
+ $settings->add(new admin_setting_configselect('checklist_outcomes_input', get_string('outcomes_input', 'checklist'),
+ get_string('config_outcomes_input', 'checklist'), 1, $options));
+}
+}
+?>
\ No newline at end of file
diff --git a/mod/checklist/styles.css b/mod/checklist/styles.css
index a1dbce98..7f3d0716 100644
--- a/mod/checklist/styles.css
+++ b/mod/checklist/styles.css
@@ -224,4 +224,16 @@ p.checklistwarning {
.checklist_progress_percent {
padding-left: 0.5em;
+}
+
+/* MODIF JF 2012/03/18 */
+.usercomment {
+ color: black;
+ background-color: #c0ffc0;
+ border: solid black 1px;
+ margin: 0 0 0 20px;
+}
+
+span.small {
+ font-size : 80%;
}
\ No newline at end of file
diff --git a/mod/checklist/updatechecks.php b/mod/checklist/updatechecks.php
index 71293a0c..0afcf2f1 100644
--- a/mod/checklist/updatechecks.php
+++ b/mod/checklist/updatechecks.php
@@ -38,33 +38,21 @@
$url = new moodle_url('/mod/checklist/view.php');
if ($id) {
- if (! $cm = get_coursemodule_from_id('checklist', $id)) {
- error('Course Module ID was incorrect');
- }
-
- if (! $course = $DB->get_record('course', array('id' => $cm->course) )) {
- error('Course is misconfigured');
- }
-
- if (! $checklist = $DB->get_record('checklist', array('id' => $cm->instance) )) {
- error('Course module is incorrect');
+ if (!$cm = get_coursemodule_from_id('checklist', $id)){
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
$url->param('id', $id);
-
} else if ($checklistid) {
- if (! $checklist = $DB->get_record('checklist', array('id' => $checklistid) )) {
- error('Course module is incorrect');
- }
- if (! $course = $DB->get_record('course', array('id' => $checklist->course) )) {
- error('Course is misconfigured');
- }
- if (! $cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
- error('Course Module ID was incorrect');
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
$url->param('checklist', $checklistid);
-
} else {
- error('You must specify a course_module ID or an instance ID');
+ print_error('error_specif_id', 'checklist'); // 'You must specify a course_module ID or an instance ID'
}
$PAGE->set_url($url);
@@ -93,4 +81,4 @@
$chk->ajaxupdatechecks($items);
}
-echo 'OK';
+echo get_string('OK', 'checklist'); // 'OK'
diff --git a/mod/checklist/upload.php b/mod/checklist/upload.php
new file mode 100644
index 00000000..49831b03
--- /dev/null
+++ b/mod/checklist/upload.php
@@ -0,0 +1,148 @@
+.
+
+/**
+ *
+ * @package mod-checklist
+ * @author JFRUITET
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+require_once(dirname(__FILE__).'/locallib.php');
+require_once(dirname(__FILE__).'file_api.php');
+require_once(dirname(dirname(dirname(__FILE__))).'/repository/lib.php');
+
+global $DB;
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$checklistid = optional_param('checklist', 0, PARAM_INT); // checklist instance ID
+$itemid = optional_param('itemid', 0, PARAM_INT); // checklist instance ID
+$userid = optional_param('userid', 0, PARAM_INT); // checklist instance ID
+
+$url = new moodle_url('/mod/checklist/upload.php');
+$returnurl=new moodle_url('/mod/checklist/view.php');
+
+if ($id) {
+ if (!$cm = get_coursemodule_from_id('checklist', $id)){
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
+ $url->param('id', $id);
+ $returnurl->param('id', $id);
+} else if ($checklistid) {
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
+ }
+ $url->param('checklist', $checklistid);
+ $returnurl->param('checklist', $checklistid);
+} else {
+ print_error('error_specif_id', 'checklist'); // 'You must specify a course_module ID or an instance ID'
+}
+
+$PAGE->set_url($url);
+require_login($course, true, $cm);
+
+$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+if (empty($userid)){
+ if (has_capability('mod/checklist:updateown', $context)) {
+ $userid = $USER->id;
+ }
+}
+
+
+if ($descriptionid) { // description associee
+ if (! $record = $DB->get_record('checklist_activite', array("id" => "$descriptionid"))) {
+ print_error('error_description', 'checklist');
+ }
+}
+if ($documentid) { // current document
+ if (! $record_document = $DB->get_record('checklist_document', array("id" => "$documentid"))) {
+ print_error('Document ID is incorrect');
+ }
+}
+
+/ Taille des telechargements
+if (!empty($checklist->maxbytes)){
+ $maxbytes=$checklist->maxbytes;
+}
+else{
+ $maxbytes=0;
+}
+
+/// If it's hidden then it's don't show anything. :)
+/// Some capability checks.
+if (empty($cm->visible)
+ && (
+ !has_capability('moodle/course:viewhiddenactivities', $context)
+ &&
+ !has_capability('mod/checklist:updateown', $context)
+ )
+
+ ) {
+ print_error('activityiscurrentlyhidden','error',$returnurl);
+}
+
+
+if ($cancel) {
+ if (!empty($SESSION->returnpage)) {
+ $return = $SESSION->returnpage;
+ unset($SESSION->returnpage);
+ redirect($return);
+ } else {
+ redirect($returnurl);
+ }
+}
+
+
+
+$PAGE->set_url($url);
+$PAGE->set_context($context);
+$title = strip_tags($course->fullname.': '.get_string('modulename', 'checklist').': '.format_string($checklist->name,true));
+$PAGE->set_title($title);
+$PAGE->set_heading($title);
+
+$options = array('subdirs'=>0, 'maxbytes'=>get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $maxbytes), 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
+
+$mform = new mod_checklist_upload_form(null,
+ array('checklist'=>$checklist->id, 'contextid'=>$context->id,
+ 'userid'=>$USER->id, 'activiteid'=>$activite_id,
+ 'filearea'=>'document', 'msg' => get_string('document_associe', 'checklist'),
+ 'mailnow' => $mailnow, 'options'=>$options));
+
+if ($mform->is_cancelled()) {
+ redirect($returnurl);
+} else if ($mform->get_data()) {
+ checklist_upload_document($mform, $checklist->id);
+ die();
+// redirect(new moodle_url('/mod/checklist/view.php', array('id'=>$cm->id)));
+}
+
+echo $OUTPUT->header();
+echo $OUTPUT->box_start('generalbox');
+$mform->display();
+echo $OUTPUT->box_end();
+echo $OUTPUT->footer();
+die();
+
+?>
\ No newline at end of file
diff --git a/mod/checklist/version.php b/mod/checklist/version.php
index 3f2299fe..43d726df 100644
--- a/mod/checklist/version.php
+++ b/mod/checklist/version.php
@@ -23,9 +23,9 @@
* @package mod/checklist
*/
-$module->version = 2012070700; // The current module version (Date: YYYYMMDDXX)
-$module->cron = 60; // Period for cron to check this module (secs)
+$module->version = 2012072614; // The current module version (Date: YYYYMMDDXX)
+$module->cron = 60; // Period for cron to check this module (secs)
$module->maturity = MATURITY_STABLE;
-$module->release = '2.x (Build: 2012070700)';
+$module->release = '2.x (Build JF: 2012072614)';
$module->requires = 2010112400;
-$module->component = 'mod_checklist';
\ No newline at end of file
+$module->component = 'mod_checklist';
diff --git a/mod/checklist/view.php b/mod/checklist/view.php
index c6b509f2..b5a0664f 100644
--- a/mod/checklist/view.php
+++ b/mod/checklist/view.php
@@ -33,33 +33,21 @@
$url = new moodle_url('/mod/checklist/view.php');
if ($id) {
- if (! $cm = get_coursemodule_from_id('checklist', $id)) {
- error('Course Module ID was incorrect');
- }
-
- if (! $course = $DB->get_record('course', array('id' => $cm->course) )) {
- error('Course is misconfigured');
- }
-
- if (! $checklist = $DB->get_record('checklist', array('id' => $cm->instance) )) {
- error('Course module is incorrect');
+ if (!$cm = get_coursemodule_from_id('checklist', $id)){
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $checklist = $DB->get_record('checklist', array('id' => $cm->instance), '*', MUST_EXIST);
$url->param('id', $id);
-
} else if ($checklistid) {
- if (! $checklist = $DB->get_record('checklist', array('id' => $checklistid) )) {
- error('Course module is incorrect');
- }
- if (! $course = $DB->get_record('course', array('id' => $checklist->course) )) {
- error('Course is misconfigured');
- }
- if (! $cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
- error('Course Module ID was incorrect');
+ $checklist = $DB->get_record('checklist', array('id' => $checklistid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $checklist->course), '*', MUST_EXIST);
+ if (!$cm = get_coursemodule_from_instance('checklist', $checklist->id, $course->id)) {
+ print_error('error_cmid', 'checklist'); // 'Course Module ID was incorrect'
}
$url->param('checklist', $checklistid);
-
} else {
- error('You must specify a course_module ID or an instance ID');
+ print_error('error_specif_id', 'checklist'); // 'You must specify a course_module ID or an instance ID'
}
$PAGE->set_url($url);