本文整理汇总了PHP中workshop_is_teacher函数的典型用法代码示例。如果您正苦于以下问题:PHP workshop_is_teacher函数的具体用法?PHP workshop_is_teacher怎么用?PHP workshop_is_teacher使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了workshop_is_teacher函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: workshop_submission_grade
function workshop_submission_grade($workshop, $submission)
{
// returns the current (external) grade of the submission based on the "good" (cold) assessments
// (needed as it's called by grade)
$grade = 0;
if ($assessments = workshop_get_assessments($submission)) {
$n = 0;
foreach ($assessments as $assessment) {
if ($workshop->agreeassessments and !$assessment->timeagreed) {
// ignore assessments which have not been agreed
continue;
}
if ($assessment->gradinggrade or !$assessment->timegraded) {
// a good assessment (or one that has not been graded yet)
if (workshop_is_teacher($workshop, $assessment->userid)) {
$timenow = time();
if ($timenow > $workshop->releasegrades) {
// teacher's grade is available
$grade += $workshop->teacherweight * $assessment->grade;
$n += $workshop->teacherweight;
}
} else {
$grade += $assessment->grade;
$n++;
}
}
}
if ($n) {
// stop division by zero
$grade = $grade / $n;
}
}
return number_format($grade * $workshop->grade / 100, 1);
}
示例2: set_field
// save number of entries in showleaguetable option
if ($nentries == 'All') {
$nentries = 99;
}
set_field("workshop", "showleaguetable", $nentries, "id", "{$workshop->id}");
// save the anonymous option
set_field("workshop", "anonymous", $anonymous, "id", "{$workshop->id}");
add_to_log($course->id, "workshop", "league table", "view.php?id={$cm->id}", $nentries, $cm->id);
redirect("view.php?id={$cm->id}");
} elseif ($action == 'updatesubmission') {
if (empty($sid)) {
error("Update submission: submission id missing");
}
$submission = get_record("workshop_submissions", "id", $sid);
// students are only allowed to update their own submission and only up to the deadline
if (!(workshop_is_teacher($workshop) or $USER->id = $submission->userid and $timenow < $workshop->submissionend and ($timenow < $workshop->assessmentstart or $timenow < $submission->timecreated + $CFG->maxeditingtime))) {
error("You are not authorized to update your submission");
}
// check existence of title
if (empty($title)) {
$title = get_string("notitle", "workshop");
}
set_field("workshop_submissions", "title", $title, "id", $submission->id);
set_field("workshop_submissions", "description", trim($description), "id", $submission->id);
set_field("workshop_submissions", "timecreated", $timenow, "id", $submission->id);
if ($workshop->nattachments) {
require_once $CFG->dirroot . '/lib/uploadlib.php';
$um = new upload_manager(null, false, false, $course, false, $workshop->maxbytes);
if ($um->preprocess_files()) {
$dir = workshop_file_area_name($workshop, $submission);
if ($um->save_files($dir)) {
示例3: foreach
if ($assessments = workshop_get_assessments($submission)) {
foreach ($assessments as $studentassessment) {
// skip if it's not a student assessment
if (!workshop_is_student($workshop, $studentassessment->userid)) {
continue;
}
$gradinggrade = workshop_compare_assessments($workshop, $assessment, $studentassessment);
set_field("workshop_assessments", "timegraded", $timenow, "id", $studentassessment->id);
set_field("workshop_assessments", "gradinggrade", $gradinggrade, "id", $studentassessment->id);
}
}
} else {
//it's a student assessment, see if there's a corresponding teacher's assessment
if ($assessments = workshop_get_assessments($submission)) {
foreach ($assessments as $teacherassessment) {
if (workshop_is_teacher($workshop, $teacherassessment->userid)) {
$gradinggrade = workshop_compare_assessments($workshop, $assessment, $teacherassessment);
set_field("workshop_assessments", "timegraded", $timenow, "id", $assessment->id);
set_field("workshop_assessments", "gradinggrade", $gradinggrade, "id", $assessment->id);
break;
// only look for the first teacher assessment
}
}
}
}
}
// any comment?
if (!empty($form->generalcomment)) {
set_field("workshop_assessments", "generalcomment", clean_param($form->generalcomment, PARAM_CLEAN), "id", $assessment->id);
}
add_to_log($course->id, "workshop", "assess", "viewassessment.php?id={$cm->id}&aid={$assessment->id}", "{$assessment->id}", "{$cm->id}");
示例4: workshop_print_submission_assessments
function workshop_print_submission_assessments($workshop, $submission, $type)
{
global $USER, $CFG;
// Returns the teacher or peer grade and a hyperlinked list of grades for this submission
if (!($cm = get_coursemodule_from_instance("workshop", $workshop->id, $workshop->course))) {
error("Course Module ID was incorrect");
}
$str = '';
// get the assessments in grade order, highest first
if ($assessments = workshop_get_assessments($submission, "", "grade DESC")) {
if ($type == 'teacher' or $type == 'all') {
// students can see teacher assessments only if the release date has passed
$timenow = time();
if (workshop_is_teacher($workshop, $USER->id) or $timenow > $workshop->releasegrades) {
foreach ($assessments as $assessment) {
if (workshop_is_teacher($workshop, $assessment->userid)) {
if ($type == 'all') {
$str .= workshop_fullname($assessment->userid, $workshop->course) . ': ';
}
$str .= "<a href=\"viewassessment.php?aid={$assessment->id}\">" . "[" . number_format($assessment->grade * $workshop->grade / 100, 0) . "]</a>";
if (workshop_is_teacher($workshop, $USER->id)) {
$str .= ' <a title="' . get_string('reassess', 'workshop') . "\" href=\"assess.php?id={$cm->id}&sid={$submission->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . ' class="iconsmall" alt="' . get_string('reassess', 'workshop') . '" /></a>';
$str .= ' <a title="' . get_string('delete', 'workshop') . "\" href=\"assessments.php?action=confirmdelete&wid={$workshop->id}&aid={$assessment->id}\"><img src=\"{$CFG->pixpath}/t/delete.gif\" " . ' class="iconsmall" alt="' . get_string('delete', 'workshop') . '" /></a><br />';
}
}
}
}
}
if ($type == 'student' or $type == 'all') {
foreach ($assessments as $assessment) {
if (workshop_is_student($workshop, $assessment->userid)) {
if ($type == 'all') {
$str .= workshop_fullname($assessment->userid, $workshop->course) . ': ';
}
$str .= "<a href=\"viewassessment.php?aid={$assessment->id}\">";
if ($workshop->agreeassessments and !$assessment->timeagreed and workshop_is_student($workshop, $submission->userid)) {
// agreement on student work only
$str .= "<<" . number_format($assessment->grade * $workshop->grade / 100, 0) . " (" . number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0) . ")>></a> ";
} elseif ($assessment->timegraded) {
if ($assessment->gradinggrade) {
$str .= "{" . number_format($assessment->grade * $workshop->grade / 100, 0);
if ($assessment->teachergraded) {
$str .= " [" . number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0) . "]}</a> ";
} else {
$str .= " (" . number_format($assessment->gradinggrade * $workshop->gradinggrade / 100, 0) . ")}</a> ";
}
} else {
$str .= "<" . number_format($assessment->grade * $workshop->grade / 100, 0) . " (0)></a> ";
}
} else {
$str .= "{" . number_format($assessment->grade * $workshop->grade / 100, 0) . "}</a> ";
}
$str .= '<br />';
}
}
}
}
if (!$str) {
$str = " ";
// be kind to Mozilla browsers!
}
return $str;
}