Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-24765 workshop logging features reviewed
  • Loading branch information
mudrd8mz committed Oct 20, 2010
1 parent c2a3526 commit 5450f7b
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 13 deletions.
1 change: 1 addition & 0 deletions mod/workshop/aggregate.php
Expand Up @@ -56,6 +56,7 @@
$workshop->aggregate_submission_grades(); // updates 'grade' in {workshop_submissions}
$evaluator->update_grading_grades($settingsdata); // updates 'gradinggrade' in {workshop_assessments}
$workshop->aggregate_grading_grades(); // updates 'gradinggrade' in {workshop_aggregations}
$workshop->log('update aggregate grades');
redirect(new moodle_url($workshop->view_url(), compact('page', 'sortby', 'sorthow')));
}

Expand Down
5 changes: 5 additions & 0 deletions mod/workshop/assessment.php
Expand Up @@ -120,6 +120,11 @@
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
if (is_null($assessment->grade)) {
$workshop->log('add assessment', $workshop->assess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update assessment', $workshop->assess_url($assessment->id), $assessment->submissionid);
}
$rawgrade = $strategy->save_assessment($assessment, $data);
if (isset($data->weight) and $cansetassessmentweight) {
$DB->set_field('workshop_assessments', 'weight', $data->weight, array('id' => $assessment->id));
Expand Down
32 changes: 26 additions & 6 deletions mod/workshop/db/log.php
Expand Up @@ -27,9 +27,29 @@
defined('MOODLE_INTERNAL') || die();

$logs = array(
//TODO copied from old install.php
//array('module'=>'workshop', 'action'=>'add', 'mtable'=>'workshop', 'field'=>'name'),
//array('module'=>'workshop', 'action'=>'update', 'mtable'=>'workshop', 'field'=>'name'),
//array('module'=>'workshop', 'action'=>'view', 'mtable'=>'workshop', 'field'=>'name'),
//array('module'=>'workshop', 'action'=>'view all', 'mtable'=>'workshop', 'field'=>'name'),
);
// workshop instance log actions
array('module'=>'workshop', 'action'=>'add', 'mtable'=>'workshop', 'field'=>'name'),
array('module'=>'workshop', 'action'=>'update', 'mtable'=>'workshop', 'field'=>'name'),
array('module'=>'workshop', 'action'=>'view', 'mtable'=>'workshop', 'field'=>'name'),
array('module'=>'workshop', 'action'=>'view all', 'mtable'=>'workshop', 'field'=>'name'),
// submission log actions
array('module'=>'workshop', 'action'=>'add submission', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'update submission', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'view submission', 'mtable'=>'workshop_submissions', 'field'=>'title'),
// assessment log actions
array('module'=>'workshop', 'action'=>'add assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'update assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
// example log actions
array('module'=>'workshop', 'action'=>'add example', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'update example', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'view example', 'mtable'=>'workshop_submissions', 'field'=>'title'),
// example assessment log actions
array('module'=>'workshop', 'action'=>'add reference assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'update reference assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'add example assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
array('module'=>'workshop', 'action'=>'update example assessment', 'mtable'=>'workshop_submissions', 'field'=>'title'),
// grading evaluation log actions
array('module'=>'workshop', 'action'=>'update aggregate grades', 'mtable'=>'workshop', 'field'=>'name'),
array('module'=>'workshop', 'action'=>'update clear aggregated grades', 'mtable'=>'workshop', 'field'=>'name'),
array('module'=>'workshop', 'action'=>'update clear assessments', 'mtable'=>'workshop', 'field'=>'name'),
);
13 changes: 13 additions & 0 deletions mod/workshop/exassessment.php
Expand Up @@ -70,6 +70,19 @@
if ($mform->is_cancelled()) {
redirect($workshop->view_url());
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
if ($canmanage) {
if (is_null($assessment->grade)) {
$workshop->log('add reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
}
} else {
if (is_null($assessment->grade)) {
$workshop->log('add example assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
} else {
$workshop->log('update example assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid);
}
}
$rawgrade = $strategy->save_assessment($assessment, $data);
if ($canmanage) {
// remember the last one who edited the reference assessment
Expand Down
5 changes: 4 additions & 1 deletion mod/workshop/exsubmission.php
Expand Up @@ -49,6 +49,8 @@

if ($id) { // example is specified
$example = $workshop->get_example_by_id($id);
$workshop->log('view example', $workshop->exsubmission_url($example->id), $example->id);

} else { // no example specified - create new one
require_capability('mod/workshop:manageexamples', $workshop->context);
$example = new stdclass();
Expand Down Expand Up @@ -136,8 +138,9 @@
$formdata->contenttrust = 0; // updated later
if (is_null($example->id)) {
$example->id = $formdata->id = $DB->insert_record('workshop_submissions', $formdata);
// todo add to log
$workshop->log('add example', $workshop->exsubmission_url($example->id), $example->id);
} else {
$workshop->log('update example', $workshop->exsubmission_url($example->id), $example->id);
if (empty($formdata->id) or empty($example->id) or ($formdata->id != $example->id)) {
throw new moodle_exception('err_examplesubmissionid', 'workshop');
}
Expand Down
37 changes: 37 additions & 0 deletions mod/workshop/locallib.php
Expand Up @@ -1092,6 +1092,27 @@ public function toolbox_url($tool) {
return new moodle_url('/mod/workshop/toolbox.php', array('id' => $this->cm->id, 'tool' => $tool));
}

/**
* Workshop wrapper around {@see add_to_log()}
*
* @param string $action to be logged
* @param moodle_url $url absolute url as returned by {@see workshop::submission_url()} and friends
* @param mixed $info additional info, usually id in a table
*/
public function log($action, moodle_url $url = null, $info = null) {

if (is_null($url)) {
$url = $this->view_url();
}

if (is_null($info)) {
$info = $this->id;
}

$logurl = $this->log_convert_url($url);
add_to_log($this->course->id, 'workshop', $action, $logurl, $info, $this->cm->id);
}

/**
* Are users allowed to create their submissions?
*
Expand Down Expand Up @@ -1961,6 +1982,22 @@ protected function available_phases_list() {
);
}

/**
* Converts absolute URL to relative URL needed by {@see add_to_log()}
*
* @param moodle_url $url absolute URL
* @return string
*/
protected function log_convert_url(moodle_url $fullurl) {
static $baseurl;

if (!isset($baseurl)) {
$baseurl = new moodle_url('/mod/workshop/');
$baseurl = $baseurl->out();
}

return substr($fullurl->out(), strlen($baseurl));
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion mod/workshop/submission.php
Expand Up @@ -47,6 +47,8 @@

if ($id) { // submission is specified
$submission = $workshop->get_submission_by_id($id);
$workshop->log('view submission', $workshop->submission_url($submission->id), $submission->id);

} else { // no submission specified
if (!$submission = $workshop->get_submission_by_author($USER->id)) {
$submission = new stdclass();
Expand Down Expand Up @@ -152,8 +154,9 @@
}
if (is_null($submission->id)) {
$submission->id = $formdata->id = $DB->insert_record('workshop_submissions', $formdata);
// todo add to log
$workshop->log('add submission', $workshop->submission_url($submission->id), $submission->id);
} else {
$workshop->log('update submission', $workshop->submission_url($submission->id), $submission->id);
if (empty($formdata->id) or empty($submission->id) or ($formdata->id != $submission->id)) {
throw new moodle_exception('err_submissionid', 'workshop');
}
Expand Down
3 changes: 2 additions & 1 deletion mod/workshop/switchphase.php
Expand Up @@ -28,7 +28,7 @@
require_once(dirname(__FILE__).'/locallib.php');

$cmid = required_param('cmid', PARAM_INT); // course module
$phase = required_param('phase', PARAM_INT); // the code of the new page
$phase = required_param('phase', PARAM_INT); // the code of the new phase
$confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation

$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
Expand All @@ -48,6 +48,7 @@
if (!$workshop->switch_phase($phase)) {
print_error('errorswitchingphase', 'workshop', $workshop->view_url());
}
$workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
redirect($workshop->view_url());
}

Expand Down
4 changes: 2 additions & 2 deletions mod/workshop/toolbox.php
Expand Up @@ -41,14 +41,14 @@
switch ($tool) {
case 'clearaggregatedgrades':
require_capability('mod/workshop:overridegrades', $workshop->context);
add_to_log($course->id, 'workshop', $tool, 'view.php?id=' . $cm->id, $workshop->name, $cm->id);
$workshop->log('update clear aggregated grades');
$workshop->clear_submission_grades();
$workshop->clear_grading_grades();
break;

case 'clearassessments':
require_capability('mod/workshop:overridegrades', $workshop->context);
add_to_log($course->id, 'workshop', $tool, 'view.php?id=' . $cm->id, $workshop->name, $cm->id);
$workshop->log('update clear assessments');
$workshop->clear_assessments();
break;
}
Expand Down
4 changes: 2 additions & 2 deletions mod/workshop/version.php
Expand Up @@ -29,6 +29,6 @@

defined('MOODLE_INTERNAL') || die();

$module->version = 2010080300;
$module->requires = 2010080300; // Requires this Moodle version
$module->version = 2010102005;
$module->requires = 2010101901; // Requires this Moodle version
//$module->cron = 60;

0 comments on commit 5450f7b

Please sign in to comment.