print_header("{$course->shortname}: {$nanogong->name}", "{$course->fullname}", "{$navigation} <a href=index.php?id={$course->id}>{$strnanogongs}</a> -> {$nanogong->name}", "", "", true, update_module_button($cm->id, $course->id, $strnanogong), navmenu($course, $cm)); ?> <br /> <?php // Print the activity description $options = new object(); $options->para = true; if ($nanogong->message != '') { print_simple_box(format_text($nanogong->message, FORMAT_HTML, $options), 'center', '70%', '', 5, 'generalbox', 'message'); } // The redirection url $url = "view.php?id={$cm->id}"; if (!empty($groupid)) { $url .= "&groupid={$groupid}"; } if (isstudent($course->id)) { // New message is submitted if ($action === "submit") { $title = required_param('title', PARAM_TEXT); // Title $path = required_param('path', PARAM_PATH); // Path if ($path == "") { error(get_string("pathmissing", "nanogong"), $url); } $message = optional_param('message', '', PARAM_CLEANHTML); // Message $error = null; if (nanogong_submit_message($nanogong, $groupid, $title, $path, $message, $error)) { redirect($url, get_string("messagesubmitted", "nanogong")); } else {
/** * Indicates if a specified user has a particular type of permission for a * particular group for this module instance. * @uses $USER * @param int $cmid The id of the module instance. This is necessary because the * same group can be used in different module instances with different * permission setups. * @param int $groupid The id of the group * @param int $permissiontype The permission type - see note on permission types * above * @userid int $userid The id of the user, defaults to the current user * @return boolean True if the user has the specified permission type, false * otherwise or if an error occurred. */ function groups_m_has_permission($cm, $groupid, $permissiontype, $userid = null) { if (!$userid) { global $USER; $userid = $USER->id; } $groupingid = groups_get_grouping_for_coursemodule($cm); if (!$groupingid || !is_object($cm) || !isset($cm->course)) { return false; } $courseid = $cm->course; $isstudent = isstudent($courseid, $userid); $isteacher = isteacher($courseid, $userid); $groupmember = groups_is_member($groupid, $userid); $memberofsomegroup = groups_is_member_of_some_group_in_grouping($userid, $groupingid); $groupingsettings = groups_get_grouping_settings($groupingid); $viewowngroup = $groupingsettings->viewowngroup; $viewallgroupsmembers = $groupingsettings->viewallgroupmembers; $viewallgroupsactivities = $groupingsettings->viewallgroupsactivities; $teachersgroupsmark = $groupingsettings->teachersgroupsmark; $teachersgroupsview = $groupingsettings->teachersgroupsview; $teachersgroupmark = $groupingsettings->teachersgroupmark; $teachersgroupview = $groupingsettings->teachersgroupview; $teachersoverride = $groupingsettings->teachersoverride; $permission = false; switch ($permissiontype) { case 'view': if ($isstudent and $groupmember or $isteacher and $groupmember or $isstudent and $viewallgroupsactivities or $isteacher and !$teachersgroupview or $isteacher and !$memberofsomegroup and $teachersoverride) { $permission = true; } break; case 'studentcontribute': if ($isstudent and $groupmember or $isteacher and $groupmember or $isteacher and !$memberofsomegroup and $teachersoverride) { $permission = true; } break; case 'teachermark': if ($isteacher and $groupmember or $isteacher and !$teachersgroupmark or $isteacher and !$memberofsomegroup and $teachersoverride) { $permission = true; } break; case 'viewmembers': if ($isstudent and $groupmember and $viewowngroup or $isstudent and $viewallgroupsmembers or $isteacher and $groupmember or $isteacher and !$teachersgroupview or $isteacher and !$memberofsomegroup and $teachersoverride or $isteacheredit) { $permission = true; } break; } return $permission; }
/** * Delete a message from the NanoGong database. **/ function nanogong_delete_message($nanogong, $messageid, &$error) { global $CFG, $USER; if (!isstudent($nanogong->course) && !isteacheredit($nanogong->course)) { $error = get_string("notincourse", "nanogong"); return false; } if ($nanogong_message = get_record("nanogong_message", "id", $messageid)) { if (isstudent($nanogong->course) && $nanogong_message->locked) { $error = get_string("lockerror", "nanogong"); return false; } $soundfile = $CFG->dataroot . $nanogong_message->path; if (file_exists($soundfile)) { @unlink($soundfile); } if (substr($CFG->release, 0, 3) == "1.9") { return delete_records("nanogong_message", "id", $nanogong_message->id) && nanogong_update_grades($nanogong, $nanogong_message->userid); } return delete_records("nanogong_message", "id", $nanogong_message->id); } return false; }
function journal_count_entries($journal, $groupid = 0) { /// Counts all the journal entries (optionally in a given group) global $CFG, $db; if ($groupid) { /// How many in a particular group? return count_records_sql("SELECT COUNT(*) \n FROM {$CFG->prefix}journal_entries j,\n {$CFG->prefix}groups_members g\n WHERE j.journal = {$journal->id} \n AND g.groupid = '{$groupid}' \n AND j.userid = g.userid"); } else { /// Count all the entries from the whole course $journals = get_records_sql("SELECT u.*\n FROM {$CFG->prefix}journal_entries j,\n {$CFG->prefix}user u \n WHERE j.userid = u.id\n AND j.journal = {$journal->id}\n ORDER BY j.modified DESC"); if (empty($journals)) { return 0; } // remove unenrolled participants foreach ($journals as $key => $user) { if (!isteacher($journal->course, $user->id) and !isstudent($journal->course, $user->id)) { unset($journals[$key]); } } return count($journals); } }
function attforblock_user_complete($course, $user, $mod, $attforblock) { /// Print a detailed representation of what a user has done with /// a given particular instance of this module, for user activity reports. require_once 'locallib.php'; if (isstudent($course->id, $user->id)) { // if (! $cm = get_coursemodule_from_instance("attforblock", $attforblock->id, $course->id)) { // error("Course Module ID was incorrect"); // } print_user_attendaces($user, $mod, $course); } //return true; }
function webquest_check_teamsmembers($webquest) { if ($membersraw = get_records("webquest_team_members", "webquestid", $webquest->id)) { foreach ($membersraw as $member) { if (!isstudent($webquest->course, $member->userid)) { if (!delete_records("webquest_team_members", "userid", $member->userid)) { error("could not check members database"); } } } } }
function getRoleForWimbaTools($courseId, $userId) { global $CFG; global $USER; $role = ""; if (strstr($CFG->release, "1.7")) { $context = get_context_instance(CONTEXT_COURSE, $courseId); } // the role of the current user is switched if (isset($USER->studentview) && $USER->studentview == 1 || isset($context) && isset($USER->switchrole) && !empty($USER->switchrole) && $USER->switchrole[$context->id] > 3) { $role = 'StudentBis'; } else { if (isstudent($courseId)) { // Student $role = 'Student'; } else { if (isadmin() || isteacher($courseId, $USER->id)) { // Admin, Teacher $role = 'Instructor'; } } if (strstr($CFG->release, "1.7")) { // 1.7.* version if (iscreator()) { // Course Creator $role = 'Instructor'; } else { if (!isteacheredit($courseId)) { // Non-editing Teacher $role = 'Student'; } } } } return $role; }
function get_content() { global $CFG, $USER, $COURSE; $usedictionary = get_record("block_dictionary","courseid",$COURSE->id); // Prevent warnings later. if (!$usedictionary) { $usedictionary = (object) array('id'=>0); } if (!$usedictionary->id > 0) { $dictionaryname = get_string('nodictionary','block_dictionary'); } else { if ($CFG->filter_dictionary_uri == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name; } elseif ($CFG->filter_dictionary_uri1 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name1; } elseif ($CFG->filter_dictionary_uri2 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name2; } elseif ($CFG->filter_dictionary_uri3== $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name3; } elseif ($CFG->filter_dictionary_uri4 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name4; } elseif ($CFG->filter_dictionary_uri5 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name5; } elseif ($CFG->filter_dictionary_uri6 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name6; } elseif ($CFG->filter_dictionary_uri7 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name7; } elseif ($CFG->filter_dictionary_uri8 == $usedictionary->dictionary) { $dictionaryname = $CFG->filter_dictionary_name8; } } if (!isstudent($COURSE->id,$USER->id)) { if($this->content !== NULL) { return $this->content; } $this->content = new stdClass; $this->content->footer = ''; $this->content->items = array(); /// Display dictionary used $this->content->items[] = get_string('selecteddictionary','block_dictionary').'<br>'.$dictionaryname; /// link to add dictionary if (!is_object($usedictionary) || !$usedictionary->id > 0) { $this->content->items[] = "<a href=\"$CFG->wwwroot/blocks/dictionary/add.php?id=".$COURSE->id."\">".get_string('add', 'block_dictionary').'</a>'; } else { $this->content->items[] = "<a href=\"$CFG->wwwroot/blocks/dictionary/edit.php?id=".$usedictionary->id."\">".get_string('edit', 'block_dictionary').'</a>'; } } else { $this->content = new stdClass; $this->content->footer = ''; $this->content->items = array(); /// Display dictionary used $this->content->items[] = '<center>'.get_string('activated','block_dictionary').'<br><b>'.$dictionaryname.'</b>'; $this->content->items[] = '<p><font size=".1em">'.get_string('instructions','block_dictionary').'</font></p></center>'; } return $this->content; }
function poll_user_eligible() { // TODO: Proper roles & capabilities return $this->poll->eligible == 'all' || $this->poll->eligible == 'students' && isstudent($this->instance->pageid) || $this->poll->eligible == 'teachers' && isteacher($this->instance->pageid); }
function exercise_print_league_table($exercise) { // print an order table of (student) submissions in grade order, only print the student's best submission when // there are multiple submissions if (!($course = get_record("course", "id", $exercise->course))) { error("Print league table: Course is misconfigured"); } $groupid = get_current_group($course->id); $nentries = $exercise->showleaguetable; if ($nentries == 99) { $nentries = 999999; // a large number } if ($exercise->anonymous and isstudent($course->id)) { $table->head = array(get_string("title", "exercise"), get_string("grade")); $table->align = array("left", "center"); $table->size = array("*", "*"); } else { // show names $table->head = array(get_string("title", "exercise"), get_string("name"), get_string("grade")); $table->align = array("left", "left", "center"); $table->size = array("*", "*", "*"); } $table->cellpadding = 2; $table->cellspacing = 0; if ($submissions = exercise_get_student_submissions($exercise, "grade", $groupid)) { $n = 1; foreach ($submissions as $submission) { if (empty($done[$submission->userid])) { if ($submission->late) { continue; } if (!($user = get_record("user", "id", $submission->userid))) { error("Print league table: user not found"); } if ($exercise->anonymous and isstudent($course->id)) { $table->data[] = array(exercise_print_submission_title($exercise, $submission), number_format($submission->grade * $exercise->grade / 100.0, 1)); } else { $table->data[] = array(exercise_print_submission_title($exercise, $submission), fullname($user), number_format($submission->grade * $exercise->grade / 100.0, 1)); } $n++; if ($n > $nentries) { break; } $done[$submission->userid] = 'ok'; } } print_heading(get_string("leaguetable", "exercise")); print_table($table); } }
function exercise_cron() { // Function to be run periodically according to the moodle cron // Finds all exercise notifications that have yet to be mailed out, and mails them global $CFG, $USER; $cutofftime = time() - $CFG->maxeditingtime; // look for new assessments if ($assessments = exercise_get_unmailed_assessments($cutofftime)) { $timenow = time(); foreach ($assessments as $assessment) { echo "Processing exercise assessment {$assessment->id}\n"; // switch on mailed if (!set_field("exercise_assessments", "mailed", "1", "id", "{$assessment->id}")) { echo "Could not update the mailed field for id {$assessment->id}\n"; } if (!($submission = get_record("exercise_submissions", "id", "{$assessment->submissionid}"))) { echo "Could not find submission {$assessment->submissionid}\n"; continue; } if (!($exercise = get_record("exercise", "id", $submission->exerciseid))) { echo "Could not find exercise record for id {$submission->exerciseid}\n"; continue; } if (!($course = get_record("course", "id", "{$exercise->course}"))) { echo "Could not find course {$exercise->course}\n"; continue; } if (!($cm = get_coursemodule_from_instance("exercise", $exercise->id, $course->id))) { error("Course Module ID was incorrect"); continue; } if (!($submissionowner = get_record("user", "id", "{$submission->userid}"))) { echo "Could not find user {$submission->userid}\n"; continue; } if (!($assessmentowner = get_record("user", "id", "{$assessment->userid}"))) { echo "Could not find user {$assessment->userid}\n"; continue; } if (!isstudent($course->id, $submissionowner->id) and !isteacher($course->id, $submissionowner->id)) { continue; // Not an active participant } if (!isstudent($course->id, $assessmentowner->id) and !isteacher($course->id, $assessmentowner->id)) { continue; // Not an active participant } // if the submission belongs to a teacher it's a student assessment. No need to email anything. if (isteacher($course->id, $submissionowner->id)) { continue; } $strexercises = get_string("modulenameplural", "exercise"); $strexercise = get_string("modulename", "exercise"); // it's an assessment, tell the submission owner $USER->lang = $submissionowner->lang; $sendto = $submissionowner; // "Your assignment \"$submission->title\" has been assessed by" $msg = get_string("mail1", "exercise", $submission->title) . ' ' . fullname($assessmentowner) . ".\n"; // "The comments and grade can be seen in the exercise assignment '$exercise->name' $msg .= get_string("mail2", "exercise", format_string($exercise->name, true)) . "\n\n"; $postsubject = "{$course->shortname}: {$strexercises}: " . format_string($exercise->name, true); $posttext = "{$course->shortname} -> {$strexercises} -> " . format_string($exercise->name, true) . "\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= $msg; // "You can see it in your exercise assignment" $posttext .= get_string("mail3", "exercise") . ":\n"; $posttext .= " {$CFG->wwwroot}/mod/exercise/view.php?id={$cm->id}\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($sendto->mailformat == 1) { // HTML $posthtml = "<p><font face=\"sans-serif\">" . "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> ->" . "<a href=\"{$CFG->wwwroot}/mod/exercise/index.php?id={$course->id}\">{$strexercises}</a> ->" . "<a href=\"{$CFG->wwwroot}/mod/exercise/view.php?id={$cm->id}\">" . format_string($exercise->name, true) . "</a></font></p>"; $posthtml .= "<hr /><font face=\"sans-serif\">"; $posthtml .= "<p>{$msg}</p>"; $posthtml .= "<p>" . get_string("mail3", "exercise") . " <a href=\"{$CFG->wwwroot}/mod/exercise/view.php?id={$cm->id}\">" . format_string($exercise->name, true) . "</a>.</p></font><hr />"; } else { $posthtml = ""; } if (!($teacher = get_teacher($course->id))) { echo "Error: can not find teacher for course {$course->id}!\n"; } if (!email_to_user($sendto, $teacher, $postsubject, $posttext, $posthtml)) { echo "Error: exercise cron: Could not send out mail for id {$submission->id} to user {$sendto->id} ({$sendto->email})\n"; } } } return true; }
function modImagegallery() { global $CFG; $id = optional_param('id', 0, PARAM_INT); $a = optional_param('a', 0, PARAM_INT); $cm = new stdClass(); $course = new stdClass(); $module = new stdClass(); $coursefields = 'id, category, shortname, fullname, guest, ' . 'maxbytes, visible, lang, theme, metacourse, ' . 'format, modinfo, numsections'; $modulefields = 'id, course, name, intro, maxbytes, maxwidth, maxheight, ' . 'allowstudentupload, imagesperpage, requirelogin, ' . 'resize, defaultcategory, shadow'; $cmfields = 'id, course, module, instance, section, ' . 'visible'; if ($id) { if (!($this->cm = get_record("course_modules", "id", $id, "", "", "", "", $cmfields))) { error("Course Module ID was incorrect"); } if (!($this->course = get_record("course", "id", $this->cm->course, "", "", "", "", $coursefields))) { error("Course is misconfigured"); } if (!($this->module = get_record("imagegallery", "id", $this->cm->instance, "", "", "", "", $modulefields))) { error("Course module is incorrect"); } } else { if (!($this->module = get_record("imagegallery", "id", $a, "", "", "", "", $modulefields))) { error("Course module is incorrect"); } if (!($this->course = get_record("course", "id", $this->module->course, "", "", "", "", $coursefields))) { error("Course is misconfigured"); } if (!($this->cm = get_coursemodule_from_instance("imagegallery", $this->module->id, $this->course->id))) { error("Course Module ID was incorrect"); } } // Free some memory. unset($coursefields, $modulefields, $cmfields); // Always require login for this module. require_course_login($this->course, $CFG->autologinguests, $this->cm); // Cache guest, student and teacher information. $this->isteacher = isteacher($this->course->id); $this->isstudent = isstudent($this->course->id); $this->isguest = isguest(); $this->isadmin = isadmin(); if (!$this->isstudent && !$this->isteacher or $this->isguest) { error(get_string('noaccess', 'imagegallery'), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}"); } }
<?php // $Id: insert_image.php,v 1.2 2006/03/28 08:26:38 janne Exp $ include "../../config.php"; $id = required_param('id', PARAM_INT); if (!($course = get_record("course", "id", $id))) { $course->fullname = ""; // Just to keep display happy, though browsing may fail } $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); $isteacher = isteacher($id); $isstudent = isstudent($id); if (!$isteacher && !$isstudent) { error("Your not allowed to use this script!"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=<?php print_string("thischarset"); ?> " /> <title><?php print_string("insertimage", "editor"); ?> </title> <script language="javascript" type="text/javascript"> var preview_window = null;
if (!($slideshow = get_record("slideshow", "id", $cm->instance))) { error("Course module is incorrect"); } } else { if (!($slideshow = get_record("slideshow", "id", $a))) { error("Course module is incorrect"); } if (!($course = get_record("course", "id", $slideshow->course))) { error("Course is misconfigured"); } if (!($cm = get_coursemodule_from_instance("slideshow", $slideshow->id, $course->id))) { error("Course Module ID was incorrect"); } } require_login($course->id); if (!isstudent($course->id) && !isteacher($course->id)) { error('Only for students and teachers'); } add_to_log($course->id, "slideshow", "view", "view.php?id={$cm->id}", "{$slideshow->id}"); if ($delete) { $data = get_record("slideshow_files", "id", $delete); if (isteacher($USER->id) || $USER->id == $data->userid) { delete_records("slideshow_files", "id", $delete); } } if ($textcomment) { $data = new object(); $data->instance = $id; $data->userid = $USER->id; $data->fileid = $p; $data->text = $textcomment;
if (!$interview->visible) { $link = "<a class=\"dimmed\" href=\"view.php?id={$interview->coursemodule}\">{$interview->name}</a>"; // Mostrar normal si es Visible } else { $link = "<a href=\"view.php?id={$interview->coursemodule}\">{$interview->name}</a>"; } // Si el formato es semanal o por temas se añade a la tabla información sobre // la sección y la entrevista a la que se refiere if ($course->format == 'weeks' or $course->format == 'topics') { $table->data[] = array($printsection, $link); } else { $table->data[] = array($link); } } // Si es estudiante del curso } elseif (isstudent($course->id, $USER->id)) { // Especifica la cabecera y alineación en que se mostrarán las distintas entrevistas // al hacer clic en el link de Entrevistas Personales de un curso if ($course->format == 'weeks') { //Si el formato del curso es semanal $table->head = array(get_string('week'), $strinterview, get_string('chosenslot', 'interview')); $table->align = array('center', 'center', 'center'); } else { if ($course->format == 'topics') { //Si el formato del curso es por temas $table->head = array(get_string('topic'), $strinterview, get_string('chosenslot', 'interview')); $table->align = array('center', 'center', 'center'); } else { $table->head = array($strinterviews, get_string('chosenslot', 'interview')); $table->align = array('center', 'center'); }
$strduration = get_string('duration', 'scheduler'); $stremail = get_string('email'); $navigation = build_navigation('', $cm); print_header_simple($scheduler->name, '', $navigation, '', '', true, update_module_button($cm->id, $course->id, $strscheduler), navmenu($course, $cm)); /// integrate module specific stylesheets overrides by theme echo '<link rel="stylesheet" href="' . $CFG->themewww . '/' . current_theme() . '/scheduler.css" type="text/css" />'; /// route to screen // teacher side if (has_capability('mod/scheduler:manage', $context)) { if ($action == 'viewstatistics') { include 'viewstatistics.php'; } elseif ($action == 'viewstudent') { include "viewstudent.php"; } elseif ($action == 'downloads') { include "downloads.php"; } elseif ($action == 'datelist') { include 'datelist.php'; } else { include 'teacherview.php'; } } elseif (isstudent($course->id) || has_capability('mod/scheduler:appoint', $context)) { include 'studentview.php'; } else { echo "<br/>"; print_simple_box(get_string('guestscantdoanything', 'scheduler'), 'center', '70%'); } /// Finish the page if (empty($nohtmleditorneeded) and $usehtmleditor) { use_html_editor($editorfields); } print_footer($course);