|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00030 defined('MOODLE_INTERNAL') || die(); 00031 00033 // Moodle core API // 00035 00043 function workshop_supports($feature) { 00044 switch($feature) { 00045 case FEATURE_GRADE_HAS_GRADE: return true; 00046 case FEATURE_GROUPS: return true; 00047 case FEATURE_GROUPINGS: return true; 00048 case FEATURE_GROUPMEMBERSONLY: return true; 00049 case FEATURE_MOD_INTRO: return true; 00050 case FEATURE_BACKUP_MOODLE2: return true; 00051 case FEATURE_COMPLETION_TRACKS_VIEWS: 00052 return true; 00053 case FEATURE_SHOW_DESCRIPTION: return true; 00054 default: return null; 00055 } 00056 } 00057 00069 function workshop_add_instance(stdclass $workshop) { 00070 global $CFG, $DB; 00071 require_once(dirname(__FILE__) . '/locallib.php'); 00072 00073 $workshop->phase = workshop::PHASE_SETUP; 00074 $workshop->timecreated = time(); 00075 $workshop->timemodified = $workshop->timecreated; 00076 $workshop->useexamples = (int)!empty($workshop->useexamples); // unticked checkbox hack 00077 $workshop->usepeerassessment = (int)!empty($workshop->usepeerassessment); // unticked checkbox hack 00078 $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); // unticked checkbox hack 00079 $workshop->latesubmissions = (int)!empty($workshop->latesubmissions); // unticked checkbox hack 00080 $workshop->evaluation = 'best'; 00081 00082 // insert the new record so we get the id 00083 $workshop->id = $DB->insert_record('workshop', $workshop); 00084 00085 // we need to use context now, so we need to make sure all needed info is already in db 00086 $cmid = $workshop->coursemodule; 00087 $DB->set_field('course_modules', 'instance', $workshop->id, array('id' => $cmid)); 00088 $context = get_context_instance(CONTEXT_MODULE, $cmid); 00089 00090 // process the custom wysiwyg editors 00091 if ($draftitemid = $workshop->instructauthorseditor['itemid']) { 00092 $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors', 00093 0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']); 00094 $workshop->instructauthorsformat = $workshop->instructauthorseditor['format']; 00095 } 00096 00097 if ($draftitemid = $workshop->instructreviewerseditor['itemid']) { 00098 $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers', 00099 0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']); 00100 $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format']; 00101 } 00102 00103 // re-save the record with the replaced URLs in editor fields 00104 $DB->update_record('workshop', $workshop); 00105 00106 // create gradebook items 00107 workshop_grade_item_update($workshop); 00108 workshop_grade_item_category_update($workshop); 00109 00110 return $workshop->id; 00111 } 00112 00121 function workshop_update_instance(stdclass $workshop) { 00122 global $CFG, $DB; 00123 require_once(dirname(__FILE__) . '/locallib.php'); 00124 00125 $workshop->timemodified = time(); 00126 $workshop->id = $workshop->instance; 00127 $workshop->useexamples = (int)!empty($workshop->useexamples); // unticked checkbox hack 00128 $workshop->usepeerassessment = (int)!empty($workshop->usepeerassessment); // unticked checkbox hack 00129 $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); // unticked checkbox hack 00130 $workshop->latesubmissions = (int)!empty($workshop->latesubmissions); // unticked checkbox hack 00131 $workshop->evaluation = 'best'; 00132 00133 // todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls 00134 // todo - if maximum grades are being changed, we should probably recalculate or invalidate them 00135 00136 $DB->update_record('workshop', $workshop); 00137 $context = get_context_instance(CONTEXT_MODULE, $workshop->coursemodule); 00138 00139 // process the custom wysiwyg editors 00140 if ($draftitemid = $workshop->instructauthorseditor['itemid']) { 00141 $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors', 00142 0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']); 00143 $workshop->instructauthorsformat = $workshop->instructauthorseditor['format']; 00144 } 00145 00146 if ($draftitemid = $workshop->instructreviewerseditor['itemid']) { 00147 $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers', 00148 0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']); 00149 $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format']; 00150 } 00151 00152 // re-save the record with the replaced URLs in editor fields 00153 $DB->update_record('workshop', $workshop); 00154 00155 // update gradebook items 00156 workshop_grade_item_update($workshop); 00157 workshop_grade_item_category_update($workshop); 00158 00159 return true; 00160 } 00161 00170 function workshop_delete_instance($id) { 00171 global $CFG, $DB; 00172 require_once($CFG->libdir.'/gradelib.php'); 00173 00174 if (! $workshop = $DB->get_record('workshop', array('id' => $id))) { 00175 return false; 00176 } 00177 00178 // delete all associated aggregations 00179 $DB->delete_records('workshop_aggregations', array('workshopid' => $workshop->id)); 00180 00181 // get the list of ids of all submissions 00182 $submissions = $DB->get_records('workshop_submissions', array('workshopid' => $workshop->id), '', 'id'); 00183 00184 // get the list of all allocated assessments 00185 $assessments = $DB->get_records_list('workshop_assessments', 'submissionid', array_keys($submissions), '', 'id'); 00186 00187 // delete the associated records from the workshop core tables 00188 $DB->delete_records_list('workshop_grades', 'assessmentid', array_keys($assessments)); 00189 $DB->delete_records_list('workshop_assessments', 'id', array_keys($assessments)); 00190 $DB->delete_records_list('workshop_submissions', 'id', array_keys($submissions)); 00191 00192 // call the static clean-up methods of all available subplugins 00193 $strategies = get_plugin_list('workshopform'); 00194 foreach ($strategies as $strategy => $path) { 00195 require_once($path.'/lib.php'); 00196 $classname = 'workshop_'.$strategy.'_strategy'; 00197 call_user_func($classname.'::delete_instance', $workshop->id); 00198 } 00199 00200 $allocators = get_plugin_list('workshopallocation'); 00201 foreach ($allocators as $allocator => $path) { 00202 require_once($path.'/lib.php'); 00203 $classname = 'workshop_'.$allocator.'_allocator'; 00204 call_user_func($classname.'::delete_instance', $workshop->id); 00205 } 00206 00207 $evaluators = get_plugin_list('workshopeval'); 00208 foreach ($evaluators as $evaluator => $path) { 00209 require_once($path.'/lib.php'); 00210 $classname = 'workshop_'.$evaluator.'_evaluation'; 00211 call_user_func($classname.'::delete_instance', $workshop->id); 00212 } 00213 00214 // finally remove the workshop record itself 00215 $DB->delete_records('workshop', array('id' => $workshop->id)); 00216 00217 // gradebook cleanup 00218 grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 0, null, array('deleted' => true)); 00219 grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 1, null, array('deleted' => true)); 00220 00221 return true; 00222 } 00223 00233 function workshop_user_outline($course, $user, $mod, $workshop) { 00234 global $CFG, $DB; 00235 require_once($CFG->libdir.'/gradelib.php'); 00236 00237 $grades = grade_get_grades($course->id, 'mod', 'workshop', $workshop->id, $user->id); 00238 00239 $submissiongrade = null; 00240 $assessmentgrade = null; 00241 00242 $info = ''; 00243 $time = 0; 00244 00245 if (!empty($grades->items[0]->grades)) { 00246 $submissiongrade = reset($grades->items[0]->grades); 00247 $info .= get_string('submissiongrade', 'workshop') . ': ' . $submissiongrade->str_long_grade . html_writer::empty_tag('br'); 00248 $time = max($time, $submissiongrade->dategraded); 00249 } 00250 if (!empty($grades->items[1]->grades)) { 00251 $assessmentgrade = reset($grades->items[1]->grades); 00252 $info .= get_string('gradinggrade', 'workshop') . ': ' . $assessmentgrade->str_long_grade; 00253 $time = max($time, $assessmentgrade->dategraded); 00254 } 00255 00256 if (!empty($info) and !empty($time)) { 00257 $return = new stdclass(); 00258 $return->time = $time; 00259 $return->info = $info; 00260 return $return; 00261 } 00262 00263 return null; 00264 } 00265 00272 function workshop_user_complete($course, $user, $mod, $workshop) { 00273 global $CFG, $DB, $OUTPUT; 00274 require_once(dirname(__FILE__).'/locallib.php'); 00275 require_once($CFG->libdir.'/gradelib.php'); 00276 00277 $workshop = new workshop($workshop, $mod, $course); 00278 $grades = grade_get_grades($course->id, 'mod', 'workshop', $workshop->id, $user->id); 00279 00280 if (!empty($grades->items[0]->grades)) { 00281 $submissiongrade = reset($grades->items[0]->grades); 00282 $info = get_string('submissiongrade', 'workshop') . ': ' . $submissiongrade->str_long_grade; 00283 echo html_writer::tag('li', $info, array('class'=>'submissiongrade')); 00284 } 00285 if (!empty($grades->items[1]->grades)) { 00286 $assessmentgrade = reset($grades->items[1]->grades); 00287 $info = get_string('gradinggrade', 'workshop') . ': ' . $assessmentgrade->str_long_grade; 00288 echo html_writer::tag('li', $info, array('class'=>'gradinggrade')); 00289 } 00290 00291 if (has_capability('mod/workshop:viewallsubmissions', $workshop->context)) { 00292 if ($submission = $workshop->get_submission_by_author($user->id)) { 00293 $title = format_string($submission->title); 00294 $url = $workshop->submission_url($submission->id); 00295 $link = html_writer::link($url, $title); 00296 $info = get_string('submission', 'workshop').': '.$link; 00297 echo html_writer::tag('li', $info, array('class'=>'submission')); 00298 } 00299 } 00300 00301 if (has_capability('mod/workshop:viewallassessments', $workshop->context)) { 00302 if ($assessments = $workshop->get_assessments_by_reviewer($user->id)) { 00303 foreach ($assessments as $assessment) { 00304 $a = new stdclass(); 00305 $a->submissionurl = $workshop->submission_url($assessment->submissionid)->out(); 00306 $a->assessmenturl = $workshop->assess_url($assessment->id)->out(); 00307 $a->submissiontitle = s($assessment->submissiontitle); 00308 echo html_writer::tag('li', get_string('assessmentofsubmission', 'workshop', $a)); 00309 } 00310 } 00311 } 00312 } 00313 00324 function workshop_print_recent_activity($course, $viewfullnames, $timestart) { 00325 global $CFG, $USER, $DB, $OUTPUT; 00326 00327 $sql = "SELECT s.id AS submissionid, s.title AS submissiontitle, s.timemodified AS submissionmodified, 00328 author.id AS authorid, author.lastname AS authorlastname, author.firstname AS authorfirstname, 00329 a.id AS assessmentid, a.timemodified AS assessmentmodified, 00330 reviewer.id AS reviewerid, reviewer.lastname AS reviewerlastname, reviewer.firstname AS reviewerfirstname, 00331 cm.id AS cmid 00332 FROM {workshop} w 00333 INNER JOIN {course_modules} cm ON cm.instance = w.id 00334 INNER JOIN {modules} md ON md.id = cm.module 00335 INNER JOIN {workshop_submissions} s ON s.workshopid = w.id 00336 INNER JOIN {user} author ON s.authorid = author.id 00337 LEFT JOIN {workshop_assessments} a ON a.submissionid = s.id 00338 LEFT JOIN {user} reviewer ON a.reviewerid = reviewer.id 00339 WHERE cm.course = ? 00340 AND md.name = 'workshop' 00341 AND s.example = 0 00342 AND (s.timemodified > ? OR a.timemodified > ?)"; 00343 00344 $rs = $DB->get_recordset_sql($sql, array($course->id, $timestart, $timestart)); 00345 00346 $modinfo =& get_fast_modinfo($course); // reference needed because we might load the groups 00347 00348 $submissions = array(); // recent submissions indexed by submission id 00349 $assessments = array(); // recent assessments indexed by assessment id 00350 $users = array(); 00351 00352 foreach ($rs as $activity) { 00353 if (!array_key_exists($activity->cmid, $modinfo->cms)) { 00354 // this should not happen but just in case 00355 continue; 00356 } 00357 00358 $cm = $modinfo->cms[$activity->cmid]; 00359 if (!$cm->uservisible) { 00360 continue; 00361 } 00362 00363 if ($viewfullnames) { 00364 // remember all user names we can use later 00365 if (empty($users[$activity->authorid])) { 00366 $u = new stdclass(); 00367 $u->lastname = $activity->authorlastname; 00368 $u->firstname = $activity->authorfirstname; 00369 $users[$activity->authorid] = $u; 00370 } 00371 if ($activity->reviewerid and empty($users[$activity->reviewerid])) { 00372 $u = new stdclass(); 00373 $u->lastname = $activity->reviewerlastname; 00374 $u->firstname = $activity->reviewerfirstname; 00375 $users[$activity->reviewerid] = $u; 00376 } 00377 } 00378 00379 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00380 $groupmode = groups_get_activity_groupmode($cm, $course); 00381 00382 if ($activity->submissionmodified > $timestart and empty($submissions[$activity->submissionid])) { 00383 $s = new stdclass(); 00384 $s->title = $activity->submissiontitle; 00385 $s->authorid = $activity->authorid; 00386 $s->timemodified = $activity->submissionmodified; 00387 $s->cmid = $activity->cmid; 00388 if (has_capability('mod/workshop:viewauthornames', $context)) { 00389 $s->authornamevisible = true; 00390 } else { 00391 $s->authornamevisible = false; 00392 } 00393 00394 // the following do-while wrapper allows to break from deeply nested if-statements 00395 do { 00396 if ($s->authorid === $USER->id) { 00397 // own submissions always visible 00398 $submissions[$activity->submissionid] = $s; 00399 break; 00400 } 00401 00402 if (has_capability('mod/workshop:viewallsubmissions', $context)) { 00403 if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { 00404 if (isguestuser()) { 00405 // shortcut - guest user does not belong into any group 00406 break; 00407 } 00408 00409 if (is_null($modinfo->groups)) { 00410 $modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo 00411 } 00412 00413 // this might be slow - show only submissions by users who share group with me in this cm 00414 if (empty($modinfo->groups[$cm->id])) { 00415 break; 00416 } 00417 $authorsgroups = groups_get_all_groups($course->id, $s->authorid, $cm->groupingid); 00418 if (is_array($authorsgroups)) { 00419 $authorsgroups = array_keys($authorsgroups); 00420 $intersect = array_intersect($authorsgroups, $modinfo->groups[$cm->id]); 00421 if (empty($intersect)) { 00422 break; 00423 } else { 00424 // can see all submissions and shares a group with the author 00425 $submissions[$activity->submissionid] = $s; 00426 break; 00427 } 00428 } 00429 00430 } else { 00431 // can see all submissions from all groups 00432 $submissions[$activity->submissionid] = $s; 00433 } 00434 } 00435 } while (0); 00436 } 00437 00438 if ($activity->assessmentmodified > $timestart and empty($assessments[$activity->assessmentid])) { 00439 $a = new stdclass(); 00440 $a->submissionid = $activity->submissionid; 00441 $a->submissiontitle = $activity->submissiontitle; 00442 $a->reviewerid = $activity->reviewerid; 00443 $a->timemodified = $activity->assessmentmodified; 00444 $a->cmid = $activity->cmid; 00445 if (has_capability('mod/workshop:viewreviewernames', $context)) { 00446 $a->reviewernamevisible = true; 00447 } else { 00448 $a->reviewernamevisible = false; 00449 } 00450 00451 // the following do-while wrapper allows to break from deeply nested if-statements 00452 do { 00453 if ($a->reviewerid === $USER->id) { 00454 // own assessments always visible 00455 $assessments[$activity->assessmentid] = $a; 00456 break; 00457 } 00458 00459 if (has_capability('mod/workshop:viewallassessments', $context)) { 00460 if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { 00461 if (isguestuser()) { 00462 // shortcut - guest user does not belong into any group 00463 break; 00464 } 00465 00466 if (is_null($modinfo->groups)) { 00467 $modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo 00468 } 00469 00470 // this might be slow - show only submissions by users who share group with me in this cm 00471 if (empty($modinfo->groups[$cm->id])) { 00472 break; 00473 } 00474 $reviewersgroups = groups_get_all_groups($course->id, $a->reviewerid, $cm->groupingid); 00475 if (is_array($reviewersgroups)) { 00476 $reviewersgroups = array_keys($reviewersgroups); 00477 $intersect = array_intersect($reviewersgroups, $modinfo->groups[$cm->id]); 00478 if (empty($intersect)) { 00479 break; 00480 } else { 00481 // can see all assessments and shares a group with the reviewer 00482 $assessments[$activity->assessmentid] = $a; 00483 break; 00484 } 00485 } 00486 00487 } else { 00488 // can see all assessments from all groups 00489 $assessments[$activity->assessmentid] = $a; 00490 } 00491 } 00492 } while (0); 00493 } 00494 } 00495 $rs->close(); 00496 00497 $shown = false; 00498 00499 if (!empty($submissions)) { 00500 $shown = true; 00501 echo $OUTPUT->heading(get_string('recentsubmissions', 'workshop'), 3); 00502 foreach ($submissions as $id => $submission) { 00503 $link = new moodle_url('/mod/workshop/submission.php', array('id'=>$id, 'cmid'=>$submission->cmid)); 00504 if ($viewfullnames and $submission->authornamevisible) { 00505 $author = $users[$submission->authorid]; 00506 } else { 00507 $author = null; 00508 } 00509 print_recent_activity_note($submission->timemodified, $author, $submission->title, $link->out(), false, $viewfullnames); 00510 } 00511 } 00512 00513 if (!empty($assessments)) { 00514 $shown = true; 00515 echo $OUTPUT->heading(get_string('recentassessments', 'workshop'), 3); 00516 foreach ($assessments as $id => $assessment) { 00517 $link = new moodle_url('/mod/workshop/assessment.php', array('asid' => $id)); 00518 if ($viewfullnames and $assessment->reviewernamevisible) { 00519 $reviewer = $users[$assessment->reviewerid]; 00520 } else { 00521 $reviewer = null; 00522 } 00523 print_recent_activity_note($assessment->timemodified, $reviewer, $assessment->submissiontitle, $link->out(), false, $viewfullnames); 00524 } 00525 } 00526 00527 if ($shown) { 00528 return true; 00529 } 00530 00531 return false; 00532 } 00533 00546 function workshop_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) { 00547 global $CFG, $COURSE, $USER, $DB; 00548 00549 if ($COURSE->id == $courseid) { 00550 $course = $COURSE; 00551 } else { 00552 $course = $DB->get_record('course', array('id'=>$courseid)); 00553 } 00554 00555 $modinfo =& get_fast_modinfo($course); 00556 00557 $cm = $modinfo->cms[$cmid]; 00558 00559 $params = array(); 00560 if ($userid) { 00561 $userselect = "AND (author.id = :authorid OR reviewer.id = :reviewerid)"; 00562 $params['authorid'] = $userid; 00563 $params['reviewerid'] = $userid; 00564 } else { 00565 $userselect = ""; 00566 } 00567 00568 if ($groupid) { 00569 $groupselect = "AND (authorgroupmembership.groupid = :authorgroupid OR reviewergroupmembership.groupid = :reviewergroupid)"; 00570 $groupjoin = "LEFT JOIN {groups_members} authorgroupmembership ON authorgroumembership.userid = author.id 00571 LEFT JOIN {groups_members} reviewergroupmembership ON reviewergroumembership.userid = reviewer.id"; 00572 $params['authorgroupid'] = $groupid; 00573 $params['reviewergroupid'] = $groupid; 00574 } else { 00575 $groupselect = ""; 00576 $groupjoin = ""; 00577 } 00578 00579 $params['cminstance'] = $cm->instance; 00580 $params['submissionmodified'] = $timestart; 00581 $params['assessmentmodified'] = $timestart; 00582 00583 $sql = "SELECT s.id AS submissionid, s.title AS submissiontitle, s.timemodified AS submissionmodified, 00584 author.id AS authorid, author.lastname AS authorlastname, author.firstname AS authorfirstname, 00585 author.picture AS authorpicture, author.imagealt AS authorimagealt, author.email AS authoremail, 00586 a.id AS assessmentid, a.timemodified AS assessmentmodified, 00587 reviewer.id AS reviewerid, reviewer.lastname AS reviewerlastname, reviewer.firstname AS reviewerfirstname, 00588 reviewer.picture AS reviewerpicture, reviewer.imagealt AS reviewerimagealt, reviewer.email AS revieweremail 00589 FROM {workshop_submissions} s 00590 INNER JOIN {workshop} w ON s.workshopid = w.id 00591 INNER JOIN {user} author ON s.authorid = author.id 00592 LEFT JOIN {workshop_assessments} a ON a.submissionid = s.id 00593 LEFT JOIN {user} reviewer ON a.reviewerid = reviewer.id 00594 $groupjoin 00595 WHERE w.id = :cminstance 00596 AND s.example = 0 00597 $userselect $groupselect 00598 AND (s.timemodified > :submissionmodified OR a.timemodified > :assessmentmodified) 00599 ORDER BY s.timemodified ASC, a.timemodified ASC"; 00600 00601 $rs = $DB->get_recordset_sql($sql, $params); 00602 00603 $groupmode = groups_get_activity_groupmode($cm, $course); 00604 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00605 $grader = has_capability('moodle/grade:viewall', $context); 00606 $accessallgroups = has_capability('moodle/site:accessallgroups', $context); 00607 $viewfullnames = has_capability('moodle/site:viewfullnames', $context); 00608 $viewauthors = has_capability('mod/workshop:viewauthornames', $context); 00609 $viewreviewers = has_capability('mod/workshop:viewreviewernames', $context); 00610 00611 if (is_null($modinfo->groups)) { 00612 $modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo 00613 } 00614 00615 $submissions = array(); // recent submissions indexed by submission id 00616 $assessments = array(); // recent assessments indexed by assessment id 00617 $users = array(); 00618 00619 foreach ($rs as $activity) { 00620 00621 if ($viewfullnames) { 00622 // remember all user names we can use later 00623 if (empty($users[$activity->authorid])) { 00624 $u = new stdclass(); 00625 $u->id = $activity->authorid; 00626 $u->lastname = $activity->authorlastname; 00627 $u->firstname = $activity->authorfirstname; 00628 $u->picture = $activity->authorpicture; 00629 $u->imagealt = $activity->authorimagealt; 00630 $u->email = $activity->authoremail; 00631 $users[$activity->authorid] = $u; 00632 } 00633 if ($activity->reviewerid and empty($users[$activity->reviewerid])) { 00634 $u = new stdclass(); 00635 $u->id = $activity->reviewerid; 00636 $u->lastname = $activity->reviewerlastname; 00637 $u->firstname = $activity->reviewerfirstname; 00638 $u->picture = $activity->reviewerpicture; 00639 $u->imagealt = $activity->reviewerimagealt; 00640 $u->email = $activity->revieweremail; 00641 $users[$activity->reviewerid] = $u; 00642 } 00643 } 00644 00645 if ($activity->submissionmodified > $timestart and empty($submissions[$activity->submissionid])) { 00646 $s = new stdclass(); 00647 $s->id = $activity->submissionid; 00648 $s->title = $activity->submissiontitle; 00649 $s->authorid = $activity->authorid; 00650 $s->timemodified = $activity->submissionmodified; 00651 if (has_capability('mod/workshop:viewauthornames', $context)) { 00652 $s->authornamevisible = true; 00653 } else { 00654 $s->authornamevisible = false; 00655 } 00656 00657 // the following do-while wrapper allows to break from deeply nested if-statements 00658 do { 00659 if ($s->authorid === $USER->id) { 00660 // own submissions always visible 00661 $submissions[$activity->submissionid] = $s; 00662 break; 00663 } 00664 00665 if (has_capability('mod/workshop:viewallsubmissions', $context)) { 00666 if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { 00667 if (isguestuser()) { 00668 // shortcut - guest user does not belong into any group 00669 break; 00670 } 00671 00672 // this might be slow - show only submissions by users who share group with me in this cm 00673 if (empty($modinfo->groups[$cm->id])) { 00674 break; 00675 } 00676 $authorsgroups = groups_get_all_groups($course->id, $s->authorid, $cm->groupingid); 00677 if (is_array($authorsgroups)) { 00678 $authorsgroups = array_keys($authorsgroups); 00679 $intersect = array_intersect($authorsgroups, $modinfo->groups[$cm->id]); 00680 if (empty($intersect)) { 00681 break; 00682 } else { 00683 // can see all submissions and shares a group with the author 00684 $submissions[$activity->submissionid] = $s; 00685 break; 00686 } 00687 } 00688 00689 } else { 00690 // can see all submissions from all groups 00691 $submissions[$activity->submissionid] = $s; 00692 } 00693 } 00694 } while (0); 00695 } 00696 00697 if ($activity->assessmentmodified > $timestart and empty($assessments[$activity->assessmentid])) { 00698 $a = new stdclass(); 00699 $a->id = $activity->assessmentid; 00700 $a->submissionid = $activity->submissionid; 00701 $a->submissiontitle = $activity->submissiontitle; 00702 $a->reviewerid = $activity->reviewerid; 00703 $a->timemodified = $activity->assessmentmodified; 00704 if (has_capability('mod/workshop:viewreviewernames', $context)) { 00705 $a->reviewernamevisible = true; 00706 } else { 00707 $a->reviewernamevisible = false; 00708 } 00709 00710 // the following do-while wrapper allows to break from deeply nested if-statements 00711 do { 00712 if ($a->reviewerid === $USER->id) { 00713 // own assessments always visible 00714 $assessments[$activity->assessmentid] = $a; 00715 break; 00716 } 00717 00718 if (has_capability('mod/workshop:viewallassessments', $context)) { 00719 if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { 00720 if (isguestuser()) { 00721 // shortcut - guest user does not belong into any group 00722 break; 00723 } 00724 00725 // this might be slow - show only submissions by users who share group with me in this cm 00726 if (empty($modinfo->groups[$cm->id])) { 00727 break; 00728 } 00729 $reviewersgroups = groups_get_all_groups($course->id, $a->reviewerid, $cm->groupingid); 00730 if (is_array($reviewersgroups)) { 00731 $reviewersgroups = array_keys($reviewersgroups); 00732 $intersect = array_intersect($reviewersgroups, $modinfo->groups[$cm->id]); 00733 if (empty($intersect)) { 00734 break; 00735 } else { 00736 // can see all assessments and shares a group with the reviewer 00737 $assessments[$activity->assessmentid] = $a; 00738 break; 00739 } 00740 } 00741 00742 } else { 00743 // can see all assessments from all groups 00744 $assessments[$activity->assessmentid] = $a; 00745 } 00746 } 00747 } while (0); 00748 } 00749 } 00750 $rs->close(); 00751 00752 $workshopname = format_string($cm->name, true); 00753 00754 if ($grader) { 00755 require_once($CFG->libdir.'/gradelib.php'); 00756 $grades = grade_get_grades($courseid, 'mod', 'workshop', $cm->instance, array_keys($users)); 00757 } 00758 00759 foreach ($submissions as $submission) { 00760 $tmpactivity = new stdclass(); 00761 $tmpactivity->type = 'workshop'; 00762 $tmpactivity->cmid = $cm->id; 00763 $tmpactivity->name = $workshopname; 00764 $tmpactivity->sectionnum = $cm->sectionnum; 00765 $tmpactivity->timestamp = $submission->timemodified; 00766 $tmpactivity->subtype = 'submission'; 00767 $tmpactivity->content = $submission; 00768 if ($grader) { 00769 $tmpactivity->grade = $grades->items[0]->grades[$submission->authorid]->str_long_grade; 00770 } 00771 if ($submission->authornamevisible and !empty($users[$submission->authorid])) { 00772 $tmpactivity->user = $users[$submission->authorid]; 00773 } 00774 $activities[$index++] = $tmpactivity; 00775 } 00776 00777 foreach ($assessments as $assessment) { 00778 $tmpactivity = new stdclass(); 00779 $tmpactivity->type = 'workshop'; 00780 $tmpactivity->cmid = $cm->id; 00781 $tmpactivity->name = $workshopname; 00782 $tmpactivity->sectionnum = $cm->sectionnum; 00783 $tmpactivity->timestamp = $assessment->timemodified; 00784 $tmpactivity->subtype = 'assessment'; 00785 $tmpactivity->content = $assessment; 00786 if ($grader) { 00787 $tmpactivity->grade = $grades->items[1]->grades[$assessment->reviewerid]->str_long_grade; 00788 } 00789 if ($assessment->reviewernamevisible and !empty($users[$assessment->reviewerid])) { 00790 $tmpactivity->user = $users[$assessment->reviewerid]; 00791 } 00792 $activities[$index++] = $tmpactivity; 00793 } 00794 } 00795 00799 function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) { 00800 global $CFG, $OUTPUT; 00801 00802 if (!empty($activity->user)) { 00803 echo html_writer::tag('div', $OUTPUT->user_picture($activity->user, array('courseid'=>$courseid)), 00804 array('style' => 'float: left; padding: 7px;')); 00805 } 00806 00807 if ($activity->subtype == 'submission') { 00808 echo html_writer::start_tag('div', array('class'=>'submission', 'style'=>'padding: 7px; float:left;')); 00809 00810 if ($detail) { 00811 echo html_writer::start_tag('h4', array('class'=>'workshop')); 00812 $url = new moodle_url('/mod/workshop/view.php', array('id'=>$activity->cmid)); 00813 $name = s($activity->name); 00814 echo html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('icon', $activity->type), 'class'=>'icon', 'alt'=>$name)); 00815 echo ' ' . $modnames[$activity->type]; 00816 echo html_writer::link($url, $name, array('class'=>'name', 'style'=>'margin-left: 5px')); 00817 echo html_writer::end_tag('h4'); 00818 } 00819 00820 echo html_writer::start_tag('div', array('class'=>'title')); 00821 $url = new moodle_url('/mod/workshop/submission.php', array('cmid'=>$activity->cmid, 'id'=>$activity->content->id)); 00822 $name = s($activity->content->title); 00823 echo html_writer::tag('strong', html_writer::link($url, $name)); 00824 echo html_writer::end_tag('div'); 00825 00826 if (!empty($activity->user)) { 00827 echo html_writer::start_tag('div', array('class'=>'user')); 00828 $url = new moodle_url('/user/view.php', array('id'=>$activity->user->id, 'course'=>$courseid)); 00829 $name = fullname($activity->user); 00830 $link = html_writer::link($url, $name); 00831 echo get_string('submissionby', 'workshop', $link); 00832 echo ' - '.userdate($activity->timestamp); 00833 echo html_writer::end_tag('div'); 00834 } else { 00835 echo html_writer::start_tag('div', array('class'=>'anonymous')); 00836 echo get_string('submission', 'workshop'); 00837 echo ' - '.userdate($activity->timestamp); 00838 echo html_writer::end_tag('div'); 00839 } 00840 00841 echo html_writer::end_tag('div'); 00842 } 00843 00844 if ($activity->subtype == 'assessment') { 00845 echo html_writer::start_tag('div', array('class'=>'assessment', 'style'=>'padding: 7px; float:left;')); 00846 00847 if ($detail) { 00848 echo html_writer::start_tag('h4', array('class'=>'workshop')); 00849 $url = new moodle_url('/mod/workshop/view.php', array('id'=>$activity->cmid)); 00850 $name = s($activity->name); 00851 echo html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('icon', $activity->type), 'class'=>'icon', 'alt'=>$name)); 00852 echo ' ' . $modnames[$activity->type]; 00853 echo html_writer::link($url, $name, array('class'=>'name', 'style'=>'margin-left: 5px')); 00854 echo html_writer::end_tag('h4'); 00855 } 00856 00857 echo html_writer::start_tag('div', array('class'=>'title')); 00858 $url = new moodle_url('/mod/workshop/assessment.php', array('asid'=>$activity->content->id)); 00859 $name = s($activity->content->submissiontitle); 00860 echo html_writer::tag('em', html_writer::link($url, $name)); 00861 echo html_writer::end_tag('div'); 00862 00863 if (!empty($activity->user)) { 00864 echo html_writer::start_tag('div', array('class'=>'user')); 00865 $url = new moodle_url('/user/view.php', array('id'=>$activity->user->id, 'course'=>$courseid)); 00866 $name = fullname($activity->user); 00867 $link = html_writer::link($url, $name); 00868 echo get_string('assessmentbyfullname', 'workshop', $link); 00869 echo ' - '.userdate($activity->timestamp); 00870 echo html_writer::end_tag('div'); 00871 } else { 00872 echo html_writer::start_tag('div', array('class'=>'anonymous')); 00873 echo get_string('assessment', 'workshop'); 00874 echo ' - '.userdate($activity->timestamp); 00875 echo html_writer::end_tag('div'); 00876 } 00877 00878 echo html_writer::end_tag('div'); 00879 } 00880 00881 echo html_writer::empty_tag('br', array('style'=>'clear:both')); 00882 } 00883 00892 function workshop_cron () { 00893 return true; 00894 } 00895 00909 function workshop_get_participants($workshopid) { 00910 global $DB; 00911 00912 $sql = "SELECT u.id 00913 FROM {workshop} w 00914 JOIN {workshop_submissions} s ON s.workshopid = w.id 00915 JOIN {user} u ON s.authorid = u.id 00916 WHERE w.id = ? AND s.example = 0 00917 00918 UNION 00919 00920 SELECT u.id 00921 FROM {workshop} w 00922 JOIN {workshop_submissions} s ON s.workshopid = w.id 00923 JOIN {workshop_assessments} a ON a.submissionid = s.id 00924 JOIN {user} u ON a.reviewerid = u.id 00925 WHERE w.id = ? AND (s.example = 0 OR a.weight = 0)"; 00926 00927 $users = array(); 00928 $rs = $DB->get_recordset_sql($sql, array($workshopid, $workshopid)); 00929 foreach ($rs as $user) { 00930 if (empty($users[$user->id])) { 00931 $users[$user->id] = $user; 00932 } 00933 } 00934 $rs->close(); 00935 00936 return $users; 00937 } 00938 00950 function workshop_scale_used($workshopid, $scaleid) { 00951 global $CFG; // other files included from here 00952 00953 $strategies = get_plugin_list('workshopform'); 00954 foreach ($strategies as $strategy => $strategypath) { 00955 $strategylib = $strategypath . '/lib.php'; 00956 if (is_readable($strategylib)) { 00957 require_once($strategylib); 00958 } else { 00959 throw new coding_exception('the grading forms subplugin must contain library ' . $strategylib); 00960 } 00961 $classname = 'workshop_' . $strategy . '_strategy'; 00962 if (method_exists($classname, 'scale_used')) { 00963 if (call_user_func_array(array($classname, 'scale_used'), array($scaleid, $workshopid))) { 00964 // no need to include any other files - scale is used 00965 return true; 00966 } 00967 } 00968 } 00969 00970 return false; 00971 } 00972 00983 function workshop_scale_used_anywhere($scaleid) { 00984 global $CFG; // other files included from here 00985 00986 $strategies = get_plugin_list('workshopform'); 00987 foreach ($strategies as $strategy => $strategypath) { 00988 $strategylib = $strategypath . '/lib.php'; 00989 if (is_readable($strategylib)) { 00990 require_once($strategylib); 00991 } else { 00992 throw new coding_exception('the grading forms subplugin must contain library ' . $strategylib); 00993 } 00994 $classname = 'workshop_' . $strategy . '_strategy'; 00995 if (method_exists($classname, 'scale_used')) { 00996 if (call_user_func(array($classname, 'scale_used'), $scaleid)) { 00997 // no need to include any other files - scale is used 00998 return true; 00999 } 01000 } 01001 } 01002 01003 return false; 01004 } 01005 01011 function workshop_get_extra_capabilities() { 01012 return array('moodle/site:accessallgroups'); 01013 } 01014 01016 // Gradebook API // 01018 01030 function workshop_grade_item_update(stdclass $workshop, $submissiongrades=null, $assessmentgrades=null) { 01031 global $CFG; 01032 require_once($CFG->libdir.'/gradelib.php'); 01033 01034 $a = new stdclass(); 01035 $a->workshopname = clean_param($workshop->name, PARAM_NOTAGS); 01036 01037 $item = array(); 01038 $item['itemname'] = get_string('gradeitemsubmission', 'workshop', $a); 01039 $item['gradetype'] = GRADE_TYPE_VALUE; 01040 $item['grademax'] = $workshop->grade; 01041 $item['grademin'] = 0; 01042 grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 0, $submissiongrades , $item); 01043 01044 $item = array(); 01045 $item['itemname'] = get_string('gradeitemassessment', 'workshop', $a); 01046 $item['gradetype'] = GRADE_TYPE_VALUE; 01047 $item['grademax'] = $workshop->gradinggrade; 01048 $item['grademin'] = 0; 01049 grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 1, $assessmentgrades, $item); 01050 } 01051 01061 function workshop_update_grades(stdclass $workshop, $userid=0) { 01062 global $CFG, $DB; 01063 require_once($CFG->libdir.'/gradelib.php'); 01064 01065 $whereuser = $userid ? ' AND authorid = :userid' : ''; 01066 $params = array('workshopid' => $workshop->id, 'userid' => $userid); 01067 $sql = 'SELECT authorid, grade, gradeover, gradeoverby, feedbackauthor, feedbackauthorformat, timemodified, timegraded 01068 FROM {workshop_submissions} 01069 WHERE workshopid = :workshopid AND example=0' . $whereuser; 01070 $records = $DB->get_records_sql($sql, $params); 01071 $submissiongrades = array(); 01072 foreach ($records as $record) { 01073 $grade = new stdclass(); 01074 $grade->userid = $record->authorid; 01075 if (!is_null($record->gradeover)) { 01076 $grade->rawgrade = grade_floatval($workshop->grade * $record->gradeover / 100); 01077 $grade->usermodified = $record->gradeoverby; 01078 } else { 01079 $grade->rawgrade = grade_floatval($workshop->grade * $record->grade / 100); 01080 } 01081 $grade->feedback = $record->feedbackauthor; 01082 $grade->feedbackformat = $record->feedbackauthorformat; 01083 $grade->datesubmitted = $record->timemodified; 01084 $grade->dategraded = $record->timegraded; 01085 $submissiongrades[$record->authorid] = $grade; 01086 } 01087 01088 $whereuser = $userid ? ' AND userid = :userid' : ''; 01089 $params = array('workshopid' => $workshop->id, 'userid' => $userid); 01090 $sql = 'SELECT userid, gradinggrade, timegraded 01091 FROM {workshop_aggregations} 01092 WHERE workshopid = :workshopid' . $whereuser; 01093 $records = $DB->get_records_sql($sql, $params); 01094 $assessmentgrades = array(); 01095 foreach ($records as $record) { 01096 $grade = new stdclass(); 01097 $grade->userid = $record->userid; 01098 $grade->rawgrade = grade_floatval($workshop->gradinggrade * $record->gradinggrade / 100); 01099 $grade->dategraded = $record->timegraded; 01100 $assessmentgrades[$record->userid] = $grade; 01101 } 01102 01103 workshop_grade_item_update($workshop, $submissiongrades, $assessmentgrades); 01104 } 01105 01114 function workshop_grade_item_category_update($workshop) { 01115 01116 $gradeitems = grade_item::fetch_all(array( 01117 'itemtype' => 'mod', 01118 'itemmodule' => 'workshop', 01119 'iteminstance' => $workshop->id, 01120 'courseid' => $workshop->course)); 01121 01122 if (!empty($gradeitems)) { 01123 foreach ($gradeitems as $gradeitem) { 01124 if ($gradeitem->itemnumber == 0) { 01125 if ($gradeitem->categoryid != $workshop->gradecategory) { 01126 $gradeitem->set_parent($workshop->gradecategory); 01127 } 01128 } else if ($gradeitem->itemnumber == 1) { 01129 if ($gradeitem->categoryid != $workshop->gradinggradecategory) { 01130 $gradeitem->set_parent($workshop->gradinggradecategory); 01131 } 01132 } 01133 } 01134 } 01135 } 01136 01138 // File API // 01140 01152 function workshop_get_file_areas($course, $cm, $context) { 01153 $areas = array(); 01154 $areas['instructauthors'] = get_string('areainstructauthors', 'workshop'); 01155 $areas['instructreviewers'] = get_string('areainstructreviewers', 'workshop'); 01156 $areas['submission_content'] = get_string('areasubmissioncontent', 'workshop'); 01157 $areas['submission_attachment'] = get_string('areasubmissionattachment', 'workshop'); 01158 01159 return $areas; 01160 } 01161 01181 function workshop_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload) { 01182 global $DB, $CFG; 01183 01184 if ($context->contextlevel != CONTEXT_MODULE) { 01185 return false; 01186 } 01187 01188 require_login($course, true, $cm); 01189 01190 if ($filearea === 'instructauthors') { 01191 // submission instructions may contain sensitive data 01192 if (!has_any_capability(array('moodle/course:manageactivities', 'mod/workshop:submit'), $context)) { 01193 send_file_not_found(); 01194 } 01195 01196 array_shift($args); // we do not use itemids here 01197 $relativepath = implode('/', $args); 01198 $fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath"; // beware, slashes are not used here! 01199 01200 $fs = get_file_storage(); 01201 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { 01202 send_file_not_found(); 01203 } 01204 01205 $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400; 01206 01207 // finally send the file 01208 send_stored_file($file, $lifetime, 0); 01209 } 01210 01211 if ($filearea === 'instructreviewers') { 01212 // submission instructions may contain sensitive data 01213 if (!has_any_capability(array('moodle/course:manageactivities', 'mod/workshop:peerassess'), $context)) { 01214 send_file_not_found(); 01215 } 01216 01217 array_shift($args); // we do not use itemids here 01218 $relativepath = implode('/', $args); 01219 $fullpath = "/$context->id/mod_workshop/$filearea/0/$relativepath"; 01220 01221 $fs = get_file_storage(); 01222 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { 01223 send_file_not_found(); 01224 } 01225 01226 $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400; 01227 01228 // finally send the file 01229 send_stored_file($file, $lifetime, 0); 01230 01231 } else if ($filearea === 'submission_content' or $filearea === 'submission_attachment') { 01232 $itemid = (int)array_shift($args); 01233 if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) { 01234 return false; 01235 } 01236 if (!$submission = $DB->get_record('workshop_submissions', array('id' => $itemid, 'workshopid' => $workshop->id))) { 01237 return false; 01238 } 01239 // TODO now make sure the user is allowed to see the file 01240 $fs = get_file_storage(); 01241 $relativepath = implode('/', $args); 01242 $fullpath = "/$context->id/mod_workshop/$filearea/$itemid/$relativepath"; 01243 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { 01244 return false; 01245 } 01246 // finally send the file 01247 // these files are uploaded by students - forcing download for security reasons 01248 send_stored_file($file, 0, 0, true); 01249 } 01250 01251 return false; 01252 } 01253 01268 function workshop_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) { 01269 global $CFG, $DB; 01270 01271 if (!has_capability('moodle/course:managefiles', $context)) { 01272 return null; 01273 } 01274 01275 $fs = get_file_storage(); 01276 01277 if ($filearea === 'content' or $filearea === 'attachment') { 01278 01279 if (is_null($itemid)) { 01280 require_once($CFG->dirroot . '/mod/workshop/fileinfolib.php'); 01281 return new workshop_file_info_submissions_container($browser, $course, $cm, $context, $areas, $filearea); 01282 } 01283 01284 // we are inside the submission container 01285 01286 $filepath = is_null($filepath) ? '/' : $filepath; 01287 $filename = is_null($filename) ? '.' : $filename; 01288 01289 if (!$storedfile = $fs->get_file($context->id, 'mod_workshop', $filearea, $itemid, $filepath, $filename)) { 01290 if ($filepath === '/' and $filename === '.') { 01291 $storedfile = new virtual_root_file($context->id, 'mod_workshop', $filearea, $itemid); 01292 } else { 01293 // not found 01294 return null; 01295 } 01296 } 01297 01298 // let us display the author's name instead of itemid (submission id) 01299 // todo some sort of caching should happen here 01300 01301 $sql = "SELECT s.id, u.lastname, u.firstname 01302 FROM {workshop_submissions} s 01303 INNER JOIN {user} u ON (s.authorid = u.id) 01304 WHERE s.workshopid = ?"; 01305 $params = array($cm->instance); 01306 $authors = $DB->get_records_sql($sql, $params); 01307 $urlbase = $CFG->wwwroot . '/pluginfile.php'; 01308 $topvisiblename = fullname($authors[$itemid]); 01309 // do not allow manual modification of any files! 01310 return new file_info_stored($browser, $context, $storedfile, $urlbase, $topvisiblename, true, true, false, false); 01311 } 01312 01313 if ($filearea == 'instructauthors' or $filearea == 'instructreviewers') { 01314 // always only itemid 0 01315 01316 $filepath = is_null($filepath) ? '/' : $filepath; 01317 $filename = is_null($filename) ? '.' : $filename; 01318 01319 $urlbase = $CFG->wwwroot.'/pluginfile.php'; 01320 if (!$storedfile = $fs->get_file($context->id, 'mod_workshop', $filearea, 0, $filepath, $filename)) { 01321 if ($filepath === '/' and $filename === '.') { 01322 $storedfile = new virtual_root_file($context->id, 'mod_workshop', $filearea, 0); 01323 } else { 01324 // not found 01325 return null; 01326 } 01327 } 01328 return new file_info_stored($browser, $context, $storedfile, $urlbase, $areas[$filearea], false, true, true, false); 01329 } 01330 } 01331 01333 // Navigation API // 01335 01346 function workshop_extend_navigation(navigation_node $navref, stdclass $course, stdclass $module, cm_info $cm) { 01347 global $CFG; 01348 01349 if (has_capability('mod/workshop:submit', get_context_instance(CONTEXT_MODULE, $cm->id))) { 01350 $url = new moodle_url('/mod/workshop/submission.php', array('cmid' => $cm->id)); 01351 $mysubmission = $navref->add(get_string('mysubmission', 'workshop'), $url); 01352 $mysubmission->mainnavonly = true; 01353 } 01354 } 01355 01365 function workshop_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $workshopnode=null) { 01366 global $PAGE; 01367 01368 //$workshopobject = $DB->get_record("workshop", array("id" => $PAGE->cm->instance)); 01369 01370 if (has_capability('mod/workshop:editdimensions', $PAGE->cm->context)) { 01371 $url = new moodle_url('/mod/workshop/editform.php', array('cmid' => $PAGE->cm->id)); 01372 $workshopnode->add(get_string('editassessmentform', 'workshop'), $url, settings_navigation::TYPE_SETTING); 01373 } 01374 if (has_capability('mod/workshop:allocate', $PAGE->cm->context)) { 01375 $url = new moodle_url('/mod/workshop/allocation.php', array('cmid' => $PAGE->cm->id)); 01376 $workshopnode->add(get_string('allocate', 'workshop'), $url, settings_navigation::TYPE_SETTING); 01377 } 01378 } 01379 01386 function workshop_page_type_list($pagetype, $parentcontext, $currentcontext) { 01387 $module_pagetype = array('mod-workshop-*'=>get_string('page-mod-workshop-x', 'workshop')); 01388 return $module_pagetype; 01389 }