当前位置: 首页>>代码示例>>PHP>>正文


PHP lesson_grade函数代码示例

本文整理汇总了PHP中lesson_grade函数的典型用法代码示例。如果您正苦于以下问题:PHP lesson_grade函数的具体用法?PHP lesson_grade怎么用?PHP lesson_grade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lesson_grade函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ongoing_score

 /**
  * Prints the on going message to the user.
  *
  * With custom grading On, displays points
  * earned out of total points possible thus far.
  * With custom grading Off, displays number of correct
  * answers out of total attempted.
  *
  * @param lesson $lesson
  * @return string
  */
 public function ongoing_score(lesson $lesson)
 {
     global $USER, $DB;
     $context = get_context_instance(CONTEXT_MODULE, $this->page->cm->id);
     if (has_capability('mod/lesson:manage', $context)) {
         return $this->output->box(get_string('teacherongoingwarning', 'lesson'), "ongoing center");
     } else {
         $ntries = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id));
         if (isset($USER->modattempts[$lesson->id])) {
             $ntries--;
         }
         $gradeinfo = lesson_grade($lesson, $ntries);
         $a = new stdClass();
         if ($lesson->custom) {
             $a->score = $gradeinfo->earned;
             $a->currenthigh = $gradeinfo->total;
             return $this->output->box(get_string("ongoingcustom", "lesson", $a), "ongoing center");
         } else {
             $a->correct = $gradeinfo->earned;
             $a->viewed = $gradeinfo->attempts;
             return $this->output->box(get_string("ongoingnormal", "lesson", $a), "ongoing center");
         }
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:35,代码来源:renderer.php

示例2: file_postupdate_standard_editor

     $essayinfo->graded = 1;
     $essayinfo->score = $form->score;
     $form = file_postupdate_standard_editor($form, 'response', $editoroptions, $context, 'mod_lesson', 'essay_responses', $attempt->id);
     $essayinfo->response = $form->response;
     $essayinfo->responseformat = $form->responseformat;
     $essayinfo->sent = 0;
     if (!$lesson->custom && $essayinfo->score == 1) {
         $attempt->correct = 1;
     } else {
         $attempt->correct = 0;
     }
     $attempt->useranswer = serialize($essayinfo);
     $DB->update_record('lesson_attempts', $attempt);
     // Get grade information
     $grade = current($grades);
     $gradeinfo = lesson_grade($lesson, $attempt->retry, $attempt->userid);
     // Set and update
     $updategrade = new stdClass();
     $updategrade->id = $grade->id;
     $updategrade->grade = $gradeinfo->grade;
     $DB->update_record('lesson_grades', $updategrade);
     $params = array('context' => $context, 'objectid' => $grade->id, 'courseid' => $course->id, 'relateduserid' => $attempt->userid, 'other' => array('lessonid' => $lesson->id, 'attemptid' => $attemptid));
     $event = \mod_lesson\event\essay_assessed::create($params);
     $event->add_record_snapshot('lesson', $dblesson);
     $event->trigger();
     $lesson->add_message(get_string('changessaved'), 'notifysuccess');
     // update central gradebook
     lesson_update_grades($lesson, $grade->userid);
     redirect(new moodle_url('/mod/lesson/essay.php', array('id' => $cm->id)));
 } else {
     print_error('invalidformdata');
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:31,代码来源:essay.php

示例3: optional_param

    }
    echo $lessoncontent;
    echo $lessonoutput->progress_bar($lesson);
    echo $lessonoutput->footer();
} else {
    $lessoncontent = '';
    // end of lesson reached work out grade
    // Used to check to see if the student ran out of time
    $outoftime = optional_param('outoftime', '', PARAM_ALPHA);
    $ntries = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id));
    if (isset($USER->modattempts[$lesson->id])) {
        $ntries--;
        // need to look at the old attempts :)
    }
    $gradelesson = true;
    $gradeinfo = lesson_grade($lesson, $ntries);
    if ($lesson->custom && !$canmanage) {
        // Before we calculate the custom score make sure they answered the minimum
        // number of questions. We only need to do this for custom scoring as we can
        // not get the miniumum score the user should achieve. If we are not using
        // custom scoring (so all questions are valued as 1) then we simply check if
        // they answered more than the minimum questions, if not, we mark it out of the
        // number specified in the minimum questions setting - which is done in lesson_grade().
        // Get the number of answers given.
        if ($gradeinfo->nquestions < $lesson->minquestions) {
            $gradelesson = false;
            $a = new stdClass();
            $a->nquestions = $gradeinfo->nquestions;
            $a->minquestions = $lesson->minquestions;
            $lessoncontent .= $OUTPUT->box_start('generalbox boxaligncenter');
            $lesson->add_message(get_string('numberofpagesviewednotice', 'lesson', $a));
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:view.php

示例4: current

         $grade = current($grades);
         $completed = $grade->completed;
         $grade = round($grade->grade, 2);
     }
     if (!($times = $DB->get_records_select("lesson_timer", "lessonid = :lessonid and userid = :userid", $params, "starttime", "*", $try, 1))) {
         $timetotake = -1;
     } else {
         $timetotake = current($times);
         $timetotake = $timetotake->lessontime - $timetotake->starttime;
     }
     if ($timetotake == -1 || $completed == -1 || $grade == -1) {
         $table->align = array("center");
         $table->data[] = array(get_string("notcompleted", "lesson"));
     } else {
         $user = $students[$userid];
         $gradeinfo = lesson_grade($lesson, $try, $user->id);
         $table->data[] = array(get_string('name') . ':', $OUTPUT->user_picture($user, array('courseid' => $course->id)) . fullname($user, true));
         $table->data[] = array(get_string("timetaken", "lesson") . ":", format_time($timetotake));
         $table->data[] = array(get_string("completed", "lesson") . ":", userdate($completed));
         $table->data[] = array(get_string('rawgrade', 'lesson') . ':', $gradeinfo->earned . '/' . $gradeinfo->total);
         $table->data[] = array(get_string("grade", "lesson") . ":", $grade . "%");
     }
     echo html_writer::table($table);
     // Don't want this class for later tables
     $table->attributes['class'] = '';
 }
 $table->align = array('left', 'left');
 $table->size = array('70%', null);
 $table->attributes['class'] = 'compacttable generaltable';
 foreach ($answerpages as $page) {
     unset($table->data);
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:report.php

示例5: lesson_print_ongoing_score

/**
 * Prints the on going message to the user.
 *
 * With custom grading On, displays points 
 * earned out of total points possible thus far.
 * With custom grading Off, displays number of correct
 * answers out of total attempted.
 *
 * @param object $lesson The lesson that the user is taking.
 * @return void
 **/
function lesson_print_ongoing_score($lesson)
{
    global $USER, $DB, $OUTPUT;
    $cm = get_coursemodule_from_instance('lesson', $lesson->id);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (has_capability('mod/lesson:manage', $context)) {
        echo "<p align=\"center\">" . get_string('teacherongoingwarning', 'lesson') . '</p>';
    } else {
        $ntries = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id));
        if (isset($USER->modattempts[$lesson->id])) {
            $ntries--;
        }
        $gradeinfo = lesson_grade($lesson, $ntries);
        $a = new stdClass();
        if ($lesson->custom) {
            $a->score = $gradeinfo->earned;
            $a->currenthigh = $gradeinfo->total;
            echo $OUTPUT->box(get_string("ongoingcustom", "lesson", $a), "generalbox boxaligncenter");
        } else {
            $a->correct = $gradeinfo->earned;
            $a->viewed = $gradeinfo->attempts;
            echo $OUTPUT->box(get_string("ongoingnormal", "lesson", $a), "generalbox boxaligncenter");
        }
    }
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:36,代码来源:locallib.php

示例6: certificate_activity_completed

function certificate_activity_completed(&$activity, &$cm, $userid = 0)
{
    global $CFG, $USER;
    static $quizid, $questid, $assid, $lessid, $feedid, $survid, $scormid, $facetofaceid;
    if (!$userid) {
        $userid = $USER->id;
    }
    if (empty($quizid)) {
        $quizid = get_field('modules', 'id', 'name', 'quiz');
        $questid = get_field('modules', 'id', 'name', 'questionnaire');
        $assid = get_field('modules', 'id', 'name', 'assignment');
        $lessid = get_field('modules', 'id', 'name', 'lesson');
        $feedid = get_field('modules', 'id', 'name', 'feedback');
        $survid = get_field('modules', 'id', 'name', 'survey');
        $scormid = get_field('modules', 'id', 'name', 'scorm');
        $facetofaceid = get_field('modules', 'id', 'name', 'facetoface');
    }
    /// If the module is not visible, it can't be accessed by students (assignment module
    /// will give us errors), so return true if its not visible.
    if (!empty($cm)) {
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
            return true;
        }
        if ($cm->module == $quizid) {
            require_once $CFG->dirroot . '/mod/quiz/locallib.php';
            $quiz = get_record('quiz', 'id', $cm->instance);
            $score = quiz_get_best_grade($quiz, $userid);
            $grade = (int) ((double) $score / (double) $quiz->grade * 100.0);
            return $grade >= (int) $activity->linkgrade;
        } else {
            if ($cm->module == $assid) {
                require_once $CFG->dirroot . '/mod/assignment/lib.php';
                $assignment = get_record('assignment', 'id', $cm->instance);
                require_once "{$CFG->dirroot}/mod/assignment/type/{$assignment->assignmenttype}/assignment.class.php";
                $assignmentclass = "assignment_{$assignment->assignmenttype}";
                $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm);
                if (!($submission = $assignmentinstance->get_submission($userid))) {
                    return false;
                } else {
                    if ($assignmentinstance->assignment->grade <= 0) {
                        return true;
                    } else {
                        $grade = (int) ((double) $submission->grade / (double) $assignmentinstance->assignment->grade * 100.0);
                        return $grade >= (int) $activity->linkgrade;
                    }
                }
            } else {
                if ($cm->module == $questid) {
                    return get_record('questionnaire_attempts', 'qid', $cm->instance, 'userid', $userid) !== false;
                } else {
                    if ($cm->module == $feedid) {
                        return get_record('feedback_completed', 'feedback', $cm->instance, 'userid', $userid) !== false;
                    } else {
                        if ($cm->module == $survid) {
                            return get_record('survey_answers', 'id', $cm->instance, 'userid', $userid) !== false;
                        } else {
                            if ($cm->module == $scormid) {
                                require_once $CFG->dirroot . '/mod/scorm/locallib.php';
                                $scorm = get_record('scorm', 'id', $cm->instance);
                                $score = scorm_grade_user($scorm, $userid);
                                if ($scorm->grademethod % 10 == 0) {
                                    // GRADESCOES
                                    if (!($scorm->maxgrade = count_records_select('scorm_scoes', "scorm='{$scorm->id}' AND launch<>'" . sql_empty() . "'"))) {
                                        return true;
                                    }
                                }
                                $return->maxgrade = $scorm->maxgrade;
                                $grade = (int) ((double) $score / (double) $scorm->maxgrade * 100.0);
                                return $grade >= (int) $activity->linkgrade;
                            } else {
                                if ($cm->module == $lessid) {
                                    require_once $CFG->dirroot . '/mod/lesson/locallib.php';
                                    if (!($lesson = get_record('lesson', 'id', $cm->instance))) {
                                        return true;
                                    } else {
                                        $ntries = count_records('lesson_grades', 'lessonid', $lesson->id, 'userid', $userid) - 1;
                                        $gradeinfo = lesson_grade($lesson, $ntries);
                                        return $gradeinfo->grade >= (int) $activity->linkgrade;
                                    }
                                } else {
                                    if ($cm->module == $facetofaceid) {
                                        require_once $CFG->libdir . '/gradelib.php';
                                        $grading_info = grade_get_grades($cm->course, 'mod', 'facetoface', $cm->instance, $userid);
                                        if (empty($grading_info)) {
                                            return false;
                                        }
                                        $grade = $grading_info->items[0]->grades[$userid]->grade;
                                        return $grade >= (int) $activity->linkgrade;
                                    } else {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:lib.php


注:本文中的lesson_grade函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。