Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions mod/checklist/README_CheckListPlus.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
CheckList - Moodle module
===========================================================================================
// Modifications by jean.fruitet@univ-nantes.fr

I made additions to original code to get some new functionnalities

CheckList Version : $module->release = 'JF-2.x (Build: 2012072614)';
This is a fork of master repositoy


1) Users may comment their Skills and upload files or URL as prove of practice.
----------------------------------------------------------------------------------

a) New DB tables 'checklist_description' and 'checklist_document'

b) New config parameter :
$CFG->checklist_description_display
New script
./mod/checklist/settings.php

c) New scripts
edit_description.php
edit_document.php
delete_description.php
delete_document.php
file_api.php

d) Scripts modification
lib.php :

// MOODLE 2.0 FILE API
function checklist_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
//Serves activite documents and other files.
function checklist_send_file($course, $cm, $context, $filearea, $args) {
// Serves activite documents and other files.

locallib.php : many functions added or modified
New function view_select_export, select_items, *_description, *_document, checklist_affiche_url
Functions modified : view_tabs, view, deleteitem, etc.


2) Import of Outcomes file (csv format) to get Outcomes as Items in CheckList
------------------------------------------------------------------------------

Teachers may import Outcomes (outcomes.csv) files in CheckList to get these outcomes as Items.
Furthermore any Item of CheckList may be validated by the way of Moodle activity
(Assignment or Quizz for exemple) which uses the same Outcomes.

a) This does not affect any CheckList DB tables

b) New config parameter :
$CFG->checklist_outcomes_input

c) New scripts :

importexportoutcomes.php
import_outcomes.php
export_outcomes.php
export_selected_outcomes.php
select_export.php
cron_outcomes.php

d) Scripts modification
lib.php ::
// Process Outcomes as Items
$outcomesupdate = 0;
if (!empty($CFG->enableoutcomes)){
require_once($CFG->dirroot.'/mod/checklist/cron_outcomes.php');
$outcomesupdate+=checklist_cron_outcomes($lastlogtime);
}
if ($outcomesupdate) {
mtrace(" Updated $outcomesupdate checkmark(s) from outcomes changes");
}

// MOODLE 2.0 FILE API
function checklist_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
//Serves activite documents and other files.
function checklist_send_file($course, $cm, $context, $filearea, $args) {
// Serves activite documents and other files.


locallib.php ::
function view_import_export() {
(...)
// MODIF JF 2012/03/18
if (USES_OUTCOMES && !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 "<a href='$importurl'>$importstr</a>&nbsp;&nbsp;<a href='$importoutcomesurl'>$importoutcomesstr</a>&nbsp;&nbsp;<a href='$exporturl'>$exportstr</a>&nbsp;&nbsp;<a href='$exportoutcomesurl'>$exportoutcomesstr</a>";
}
else{
echo "<a href='$importurl'>$importstr</a> &nbsp;&nbsp;&nbsp; <a href='$exporturl'>$exportstr</a>";
}
(...)
}

autoupdate.php
In function checklist_autoupdate(
// MODIF JF 2012/03/18
if ($module == 'referentiel') {
return 0;
}

New localisation strings

lang/en/checklist.php :: new strings
lang/fr/checklist.php :: new strings and translation

Functions replacement :
In all scripts
error('error_message') -> print_error(get_string('error_code', 'checklist'));


3) Backup / Restore :
------------------------------------------------------------------------------
./mod/checklist/backup/moodle2 scripts completed for new tables

4) Installation
------------------------------------------------------------------------------
./mod/checklist/install.xml
./mod/checklist/upgrade.php


===========================================================================================
113 changes: 113 additions & 0 deletions mod/checklist/add_document.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

// This file is part of the Checklist plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Add a new document to a description
* @author David Smith <moodle@davosmith.co.uk>
* @author Jean Fruitet <jean.fruitet@univ-nantes.fr>
* @package mod/checklist
*/


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'); // Moodle 2 file API
require_once(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);


$url = new moodle_url('/mod/checklist/add_document.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_class($cm->id, 0, $checklist, $cm, $course)) {
$chk->add_document($itemid, $userid, $descriptionid);
}

4 changes: 3 additions & 1 deletion mod/checklist/autoupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ function checklist_autoupdate($courseid, $module, $action, $cmid, $userid, $url,
if ($userid == 0) {
return 0;
}

if ($module == 'referentiel') { // Skills repository module
return 0;
}
if ($module == 'course') {
return 0;
}
Expand Down
23 changes: 21 additions & 2 deletions mod/checklist/backup/moodle2/backup_checklist_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ protected function define_structure() {
$comment = new backup_nested_element('comment', array('id'), array(
'userid', 'commentby', 'text'));

// Build the tree
$descriptions = new backup_nested_element('descriptions');

$description = new backup_nested_element('description', array('id'), array(
'userid', 'description', 'timestamp'));

$documents = new backup_nested_element('documents');

$document = new backup_nested_element('document', array('id'), array(
'descriptionid', 'description_document', 'url_document', 'target', 'title', 'timestamp'));

// Build the tree
$checklist->add_child($items);
$items->add_child($item);

Expand All @@ -62,13 +72,20 @@ protected function define_structure() {
$item->add_child($comments);
$comments->add_child($comment);

$item->add_child($descriptions);
$descriptions->add_child($description);
$description->add_child($documents);
$documents->add_child($document);

// Define sources
$checklist->set_source_table('checklist', array('id' => backup::VAR_ACTIVITYID));

if ($userinfo) {
$item->set_source_table('checklist_item', array('checklist' => backup::VAR_PARENTID));
$check->set_source_table('checklist_check', array('item' => backup::VAR_PARENTID));
$comment->set_source_table('checklist_comment', array('itemid' => backup::VAR_PARENTID));
$description->set_source_table('checklist_description', array('itemid' => backup::VAR_PARENTID));
$document->set_source_table('checklist_document', array('descriptionid' => backup::VAR_PARENTID));
} else {
$item->set_source_sql('SELECT * FROM {checklist_item} WHERE userid = 0 AND checklist = ?', array(backup::VAR_PARENTID));
}
Expand All @@ -79,10 +96,12 @@ protected function define_structure() {
$check->annotate_ids('user', 'userid');
$comment->annotate_ids('user', 'userid');
$comment->annotate_ids('user', 'commentby');

$description->annotate_ids('user', 'userid');

// Define file annotations

$checklist->annotate_files('mod_checklist', 'intro', null); // This file area hasn't itemid
$checklist->annotate_files('mod_checklist', 'document', 'id'); // This file area has itemid

// Return the root element (forum), wrapped into standard activity structure
return $this->prepare_activity_structure($checklist);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ static public function define_decode_rules() {
// Checklist edit by cm->id and forum->id
$rules[] = new restore_decode_rule('CHECKLISTEDITBYID', '/mod/checklist/edit.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYCHECKLIST', '/mod/checklist/edit.php?checklist=$1', 'checklist');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYID', '/mod/checklist/edit_description.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYCHECKLIST', '/mod/checklist/edit_description.php?checklist=$1', 'checklist');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYID', '/mod/checklist/edit_document.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYCHECKLIST', '/mod/checklist/edit_document.php?checklist=$1', 'checklist');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYID', '/mod/checklist/delete_description.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYCHECKLIST', '/mod/checklist/delete_description.php?checklist=$1', 'checklist');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYID', '/mod/checklist/delete_document.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('CHECKLISTEDITBYCHECKLIST', '/mod/checklist/delete_document.php?checklist=$1', 'checklist');

return $rules;
}
Expand Down
36 changes: 36 additions & 0 deletions mod/checklist/backup/moodle2/restore_checklist_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected function define_structure() {
if ($userinfo) {
$paths[] = new restore_path_element('checklist_check', '/activity/checklist/items/item/checks/check');
$paths[] = new restore_path_element('checklist_comment', '/activity/checklist/items/item/comments/comment');
$paths[] = new restore_path_element('checklist_description', '/activity/checklist/items/item/descriptions/description');
$paths[] = new restore_path_element('checklist_document', '/activity/checklist/items/item/descriptions/description/documents/document');
}

// Return the paths wrapped into standard activity structure
Expand Down Expand Up @@ -119,6 +121,40 @@ protected function process_checklist_comment($data) {
$this->set_mapping('checklist_comment', $oldid, $newid);
}


protected function process_checklist_description($data) {
global $DB;

$data = (object)$data;
$oldid = $data->id;

$data->itemid = $this->get_new_parentid('checklist_item');
$data->userid = $this->get_mappingid('user', $data->userid);
if ($data->timestamp > 0) {
$data->timestamp = $this->apply_date_offset($data->timestamp);
}

$newid = $DB->insert_record('checklist_description', $data);
$this->set_mapping('checklist_description', $oldid, $newid);
}


protected function process_checklist_document($data) {
global $DB;

$data = (object)$data;
$oldid = $data->id;

$data->descriptionid = $this->get_new_parentid('checklist_description');

if ($data->timestamp > 0) {
$data->timestamp = $this->apply_date_offset($data->timestamp);
}

$newid = $DB->insert_record('checklist_document', $data);
$this->set_mapping('checklist_document', $oldid, $newid);
}

protected function after_execute() {
global $DB;

Expand Down
Loading