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


PHP quiz_save_best_grade函数代码示例

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


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

示例1: print_error

    if (!$success) {
        $pagebit = '';
        if ($page) {
            $pagebit = '&page=' . $page;
        }
        print_error('errorprocessingresponses', 'question', $CFG->wwwroot . '/mod/quiz/attempt.php?q=' . $quiz->id . $pagebit);
    }
    add_to_log($course->id, 'quiz', 'close attempt', 'review.php?attempt=' . $attempt->id, $quiz->id, $cm->id);
}
/// Update the quiz attempt and the overall grade for the quiz
if ($responses || $finishattempt) {
    if (!update_record('quiz_attempts', $attempt)) {
        error('Failed to save the current quiz attempt!');
    }
    if ($attempt->attempt > 1 || $attempt->timefinish > 0 and !$attempt->preview) {
        quiz_save_best_grade($quiz);
    }
}
/// Send emails to those who have the capability set
if ($finishattempt && !$attempt->preview) {
    quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm);
}
if ($finishattempt) {
    if (!empty($SESSION->passwordcheckedquizzes[$quiz->id])) {
        unset($SESSION->passwordcheckedquizzes[$quiz->id]);
    }
    redirect($CFG->wwwroot . '/mod/quiz/review.php?attempt=' . $attempt->id, 0);
}
// Now is the right time to check the open and close times.
if (!$ispreviewing && ($timestamp < $quiz->timeopen || $quiz->timeclose && $timestamp > $quiz->timeclose)) {
    print_error('notavailable', 'quiz', "view.php?id={$cm->id}");
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:attempt.php

示例2: display


//.........这里部分代码省略.........
             error("Unable to load questiontype specific question information");
         }
         // This will have extended the question object so that it now holds
         // all the information about the questions that may be needed later.
     }
     add_to_log($course->id, "quiz", "manualgrading", "report.php?mode=grading&amp;q={$quiz->id}", "{$quiz->id}", "{$cm->id}");
     echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
     // for overlib
     if ($data = data_submitted()) {
         // post data submitted, process it
         require_sesskey();
         // now go through all of the responses and save them.
         $allok = true;
         foreach ($data->manualgrades as $uniqueid => $response) {
             // get our attempt
             $uniqueid = clean_param($uniqueid, PARAM_INT);
             if (!($attempt = get_record_sql("SELECT * FROM {$CFG->prefix}quiz_attempts " . "WHERE uniqueid = {$uniqueid} AND " . "userid IN ({$this->userids}) AND " . "quiz=" . $quiz->id))) {
                 error('No such attempt ID exists');
             }
             // Load the state for this attempt (The questions array was created earlier)
             $states = get_question_states($questions, $quiz, $attempt);
             // The $states array is indexed by question id but because we are dealing
             // with only one question there is only one entry in this array
             $state =& $states[$question->id];
             // the following will update the state and attempt
             $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']);
             if (is_string($error)) {
                 notify($error);
                 $allok = false;
             } else {
                 if ($state->changed) {
                     // If the state has changed save it and update the quiz grade
                     save_question_session($question, $state);
                     quiz_save_best_grade($quiz, $attempt->userid);
                 }
             }
         }
         if ($allok) {
             notify(get_string('changessaved', 'quiz'), 'notifysuccess');
         } else {
             notify(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess');
         }
     }
     $this->viewurl = new moodle_url($CFG->wwwroot . '/mod/quiz/report.php', $viewoptions);
     /// find out current groups mode
     if ($groupmode = groups_get_activity_groupmode($this->cm)) {
         // Groups are being used
         groups_print_activity_menu($this->cm, $this->viewurl->out(false, array('userid' => 0, 'attemptid' => 0)));
     }
     echo '<div class="quizattemptcounts">' . quiz_num_attempt_summary($quiz, $cm, true, $currentgroup) . '</div>';
     if (empty($this->users)) {
         if ($currentgroup) {
             notify(get_string('nostudentsingroup'));
         } else {
             notify(get_string('nostudentsyet'));
         }
         return true;
     }
     $gradeablequestionids = implode(',', array_keys($gradeableqs));
     $qattempts = quiz_get_total_qas_graded_and_ungraded($quiz, $gradeablequestionids, $this->userids);
     if (empty($qattempts)) {
         notify(get_string('noattemptstoshow', 'quiz'));
         return true;
     }
     $qmenu = array();
     foreach ($gradeableqs as $qid => $questionformenu) {
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:67,代码来源:report.php

示例3: quiz_delete_attempt

/**
 * Delete a quiz attempt.
 * @param mixed $attempt an integer attempt id or an attempt object
 *      (row of the quiz_attempts table).
 * @param object $quiz the quiz object.
 */
function quiz_delete_attempt($attempt, $quiz) {
    global $DB;
    if (is_numeric($attempt)) {
        if (!$attempt = $DB->get_record('quiz_attempts', array('id' => $attempt))) {
            return;
        }
    }

    if ($attempt->quiz != $quiz->id) {
        debugging("Trying to delete attempt $attempt->id which belongs to quiz $attempt->quiz " .
                "but was passed quiz $quiz->id.");
        return;
    }

    question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
    $DB->delete_records('quiz_attempts', array('id' => $attempt->id));

    // Search quiz_attempts for other instances by this user.
    // If none, then delete record for this quiz, this user from quiz_grades
    // else recalculate best grade.
    $userid = $attempt->userid;
    if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
        $DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
    } else {
        quiz_save_best_grade($quiz, $userid);
    }

    quiz_update_grades($quiz, $userid);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:35,代码来源:locallib.php

示例4: error

// Some of the questions code is optimised to work with several questions
// at once so it wants the question to be in an array.
$key = $question->id;
$questions[$key] =& $question;
// Add additional questiontype specific information to the question objects.
if (!get_question_options($questions)) {
    error("Unable to load questiontype specific question information");
}
// Load state
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state =& $states[$question->id];
print_header();
print_heading(format_string($question->name));
//add_to_log($course->id, 'quiz', 'review', "review.php?id=$cm->id&amp;attempt=$attempt->id", "$quiz->id", "$cm->id");
if ($data = data_submitted() and confirm_sesskey()) {
    // the following will update the state and attempt
    question_process_comment($question, $state, $attempt, $data->response['comment'], $data->response['grade']);
    // If the state has changed save it and update the quiz grade
    if ($state->changed) {
        save_question_session($question, $state);
        quiz_save_best_grade($quiz, $attempt->userid);
    }
    notify(get_string('changessaved'));
    echo '<div class="boxaligncenter"><input type="button" onclick="window.opener.location.reload(1); self.close();return false;" value="' . get_string('closewindow') . "\" /></div>";
    print_footer();
    exit;
}
question_print_comment_box($question, $state, $attempt, $CFG->wwwroot . '/mod/quiz/comment.php');
print_footer();
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:comment.php

示例5: display

 /**
  * Displays the report.
  */
 function display($quiz, $cm, $course)
 {
     global $CFG, $QTYPES, $DB, $OUTPUT, $PAGE;
     $viewoptions = array('mode' => 'grading', 'q' => $quiz->id);
     if ($questionid = optional_param('questionid', 0, PARAM_INT)) {
         $viewoptions += array('questionid' => $questionid);
     }
     // grade question specific parameters
     if ($userid = optional_param('userid', 0, PARAM_INT)) {
         $viewoptions += array('userid' => $userid);
     }
     if ($attemptid = optional_param('attemptid', 0, PARAM_INT)) {
         $viewoptions += array('attemptid' => $attemptid);
     }
     if ($gradeall = optional_param('gradeall', 0, PARAM_INT)) {
         $viewoptions += array('gradeall' => $gradeall);
     }
     if ($gradeungraded = optional_param('gradeungraded', 0, PARAM_INT)) {
         $viewoptions += array('gradeungraded' => $gradeungraded);
     }
     if ($gradenextungraded = optional_param('gradenextungraded', 0, PARAM_INT)) {
         $viewoptions += array('gradenextungraded' => $gradenextungraded);
     }
     $this->cm = $cm;
     $this->print_header_and_tabs($cm, $course, $quiz, $reportmode = "grading");
     // Check permissions
     $this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!has_capability('mod/quiz:grade', $this->context)) {
         echo $OUTPUT->notification(get_string('gradingnotallowed', 'quiz_grading'));
         return true;
     }
     $gradeableqs = quiz_report_load_questions($quiz);
     $questionsinuse = implode(',', array_keys($gradeableqs));
     foreach ($gradeableqs as $qid => $question) {
         if (!$QTYPES[$question->qtype]->is_question_manual_graded($question, $questionsinuse)) {
             unset($gradeableqs[$qid]);
         }
     }
     if (empty($gradeableqs)) {
         echo $OUTPUT->heading(get_string('noessayquestionsfound', 'quiz'));
         return true;
     } else {
         if (count($gradeableqs) == 1) {
             $questionid = array_shift(array_keys($gradeableqs));
         }
     }
     $currentgroup = groups_get_activity_group($this->cm, true);
     $this->users = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', $currentgroup, '', false);
     if (!empty($questionid)) {
         if (!isset($gradeableqs[$questionid])) {
             print_error('invalidquestionid', 'quiz_grading', '', $questionid);
         } else {
             $question =& $gradeableqs[$questionid];
         }
         // Some of the questions code is optimised to work with several questions
         // at once so it wants the question to be in an array. The array key
         // must be the question id.
         $key = $question->id;
         $questions[$key] =& $question;
         // We need to add additional questiontype specific information to
         // the question objects.
         if (!get_question_options($questions)) {
             print_error('cannotloadquestioninfo', 'quiz_grading');
         }
         // This will have extended the question object so that it now holds
         // all the information about the questions that may be needed later.
     }
     add_to_log($course->id, "quiz", "manualgrading", "report.php?mode=grading&amp;q={$quiz->id}", "{$quiz->id}", "{$cm->id}");
     if ($data = data_submitted()) {
         // post data submitted, process it
         if (confirm_sesskey() && $this->users) {
             // now go through all of the responses and save them.
             $allok = true;
             foreach ($data->manualgrades as $uniqueid => $response) {
                 // get our attempt
                 $uniqueid = clean_param($uniqueid, PARAM_INT);
                 list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users));
                 if (!($attempt = $DB->get_record_sql("SELECT * FROM {quiz_attempts} " . "WHERE uniqueid = ? AND " . "userid {$usql} AND " . "quiz=?", array_merge(array($uniqueid), $params, array($quiz->id))))) {
                     print_error('invalidattemptid', 'quiz_grading');
                 }
                 // Load the state for this attempt (The questions array was created earlier)
                 $states = get_question_states($questions, $quiz, $attempt);
                 // The $states array is indexed by question id but because we are dealing
                 // with only one question there is only one entry in this array
                 $state =& $states[$question->id];
                 // the following will update the state and attempt
                 $error = question_process_comment($question, $state, $attempt, $response['comment'], FORMAT_HTML, $response['grade']);
                 if (is_string($error)) {
                     echo $OUTPUT->notification($error);
                     $allok = false;
                 } else {
                     if ($state->changed) {
                         // If the state has changed save it and update the quiz grade
                         save_question_session($question, $state);
                         quiz_save_best_grade($quiz, $attempt->userid);
                     }
                 }
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:report.php

示例6: check_overall_grades

    function check_overall_grades($quiz, $userids=array(), $attemptids=array()) {
        global $DB;
        //recalculate $attempt->sumgrade
        //already updated in regrade_question_in_attempt
        $sql = "UPDATE {quiz_attempts} SET sumgrades= " .
                    "COALESCE((SELECT SUM(qs.grade) FROM {question_sessions} qns, {question_states} qs " .
                        "WHERE qns.newgraded = qs.id AND qns.attemptid = {quiz_attempts}.uniqueid ), 0) WHERE ";
        $attemptsql='';
        if (!$attemptids) {
            if ($userids) {
                list($usql, $params) = $DB->get_in_or_equal($userids);
                $attemptsql .= "{quiz_attempts}.userid $usql AND ";
            } else {
                $params = array();
            }
            $attemptsql .= "{quiz_attempts}.quiz =? AND preview = 0";
            $params[] = $quiz->id;
        } else {
            list($asql, $params) = $DB->get_in_or_equal($attemptids);
            $attemptsql .= "{quiz_attempts}.uniqueid $asql";
        }
        $sql .= $attemptsql;
        if (!$DB->execute($sql, $params)) {
            print_error('err_failedtorecalculateattemptgrades', 'quiz_overview');
        }

        // Update the overall quiz grades
        if ($attemptids) {
            //make sure we fetch all attempts for users to calculate grade.
            //not just those that have changed.
            $sql = "SELECT qa2.* FROM {quiz_attempts} qa2 WHERE " .
                    "qa2.userid IN (SELECT DISTINCT userid FROM {quiz_attempts} WHERE $attemptsql) " .
                    "AND qa2.timefinish > 0";
        } else {
            $sql = "SELECT * FROM {quiz_attempts} WHERE $attemptsql AND timefinish > 0";
        }
        if ($attempts = $DB->get_records_sql($sql, $params)) {
            $attemptsbyuser = quiz_report_index_by_keys($attempts, array('userid', 'id'));
            foreach($attemptsbyuser as $userid => $attemptsforuser) {
                quiz_save_best_grade($quiz, $userid, $attemptsforuser);
            }
        }
    }
开发者ID:nuckey,项目名称:moodle,代码行数:43,代码来源:report.php

示例7: finish_attempt

 public function finish_attempt($timestamp)
 {
     global $DB, $USER;
     $this->quba->process_all_actions($timestamp);
     $this->quba->finish_all_questions($timestamp);
     question_engine::save_questions_usage_by_activity($this->quba);
     $this->attempt->timemodified = $timestamp;
     $this->attempt->timefinish = $timestamp;
     $this->attempt->sumgrades = $this->quba->get_total_mark();
     $DB->update_record('quiz_attempts', $this->attempt);
     if (!$this->is_preview()) {
         quiz_save_best_grade($this->get_quiz());
         // Trigger event
         $eventdata = new stdClass();
         $eventdata->component = 'mod_quiz';
         $eventdata->attemptid = $this->attempt->id;
         $eventdata->timefinish = $this->attempt->timefinish;
         $eventdata->userid = $this->attempt->userid;
         $eventdata->submitterid = $USER->id;
         $eventdata->quizid = $this->get_quizid();
         $eventdata->cmid = $this->get_cmid();
         $eventdata->courseid = $this->get_courseid();
         events_trigger('quiz_attempt_submitted', $eventdata);
         // Clear the password check flag in the session.
         $this->get_access_manager($timestamp)->clear_password_access();
     }
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:27,代码来源:attemptlib.php

示例8: quiz_delete_attempt

/**
 * Delete a quiz attempt.
 * @param mixed $attempt an integer attempt id or an attempt object
 *      (row of the quiz_attempts table).
 * @param object $quiz the quiz object.
 */
function quiz_delete_attempt($attempt, $quiz)
{
    global $DB;
    if (is_numeric($attempt)) {
        if (!($attempt = $DB->get_record('quiz_attempts', array('id' => $attempt)))) {
            return;
        }
    }
    if ($attempt->quiz != $quiz->id) {
        debugging("Trying to delete attempt {$attempt->id} which belongs to quiz {$attempt->quiz} " . "but was passed quiz {$quiz->id}.");
        return;
    }
    if (!isset($quiz->cmid)) {
        $cm = get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course);
        $quiz->cmid = $cm->id;
    }
    question_engine::delete_questions_usage_by_activity($attempt->uniqueid);
    $DB->delete_records('quiz_attempts', array('id' => $attempt->id));
    // Log the deletion of the attempt.
    $params = array('objectid' => $attempt->id, 'relateduserid' => $attempt->userid, 'context' => context_module::instance($quiz->cmid), 'other' => array('quizid' => $quiz->id));
    $event = \mod_quiz\event\attempt_deleted::create($params);
    $event->add_record_snapshot('quiz_attempts', $attempt);
    $event->trigger();
    // Search quiz_attempts for other instances by this user.
    // If none, then delete record for this quiz, this user from quiz_grades
    // else recalculate best grade.
    $userid = $attempt->userid;
    if (!$DB->record_exists('quiz_attempts', array('userid' => $userid, 'quiz' => $quiz->id))) {
        $DB->delete_records('quiz_grades', array('userid' => $userid, 'quiz' => $quiz->id));
    } else {
        quiz_save_best_grade($quiz, $userid);
    }
    quiz_update_grades($quiz, $userid);
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:40,代码来源:locallib.php

示例9: display

 /**
  * Display the report.
  */
 function display($quiz, $cm, $course)
 {
     global $CFG, $SESSION, $db, $QTYPES;
     // Define some strings
     $strreallydel = addslashes(get_string('deleteattemptcheck', 'quiz'));
     $strtimeformat = get_string('strftimedatetime');
     $strreviewquestion = get_string('reviewresponse', 'quiz');
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     // Only print headers if not asked to download data
     if (!($download = optional_param('download', NULL))) {
         $this->print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview");
     }
     // Deal with actions
     $action = optional_param('action', '', PARAM_ACTION);
     switch ($action) {
         case 'delete':
             // Some attempts need to be deleted
             require_capability('mod/quiz:deleteattempts', $context);
             $attemptids = optional_param('attemptid', array(), PARAM_INT);
             foreach ($attemptids as $attemptid) {
                 if ($attemptid && ($todelete = get_record('quiz_attempts', 'id', $attemptid))) {
                     add_to_log($course->id, 'quiz', 'delete attempt', 'report.php?id=' . $cm->id, $attemptid, $cm->id);
                     delete_records('quiz_attempts', 'id', $attemptid);
                     delete_attempt($todelete->uniqueid);
                     // Search quiz_attempts for other instances by this user.
                     // If none, then delete record for this quiz, this user from quiz_grades
                     // else recalculate best grade
                     $userid = $todelete->userid;
                     if (!record_exists('quiz_attempts', 'userid', $userid, 'quiz', $quiz->id)) {
                         delete_records('quiz_grades', 'userid', $userid, 'quiz', $quiz->id);
                     } else {
                         quiz_save_best_grade($quiz, $userid);
                     }
                 }
             }
             break;
     }
     // Set of format options for teacher-created content, for example overall feedback.
     $nocleanformatoptions = new stdClass();
     $nocleanformatoptions->noclean = true;
     // Set table options
     $noattempts = optional_param('noattempts', 0, PARAM_INT);
     $detailedmarks = optional_param('detailedmarks', 0, PARAM_INT);
     $pagesize = optional_param('pagesize', 10, PARAM_INT);
     $reporturl = $CFG->wwwroot . '/mod/quiz/report.php?mode=overview';
     $reporturlwithoptions = $reporturl . '&amp;id=' . $cm->id . '&amp;noattempts=' . $noattempts . '&amp;detailedmarks=' . $detailedmarks . '&amp;pagesize=' . $pagesize;
     // Print information on the number of existing attempts
     if (!$download) {
         //do not print notices when downloading
         if ($attemptnum = count_records('quiz_attempts', 'quiz', $quiz->id, 'preview', 0)) {
             $a = new stdClass();
             $a->attemptnum = $attemptnum;
             $a->studentnum = count_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND preview = '0'", 'COUNT(DISTINCT userid)');
             $a->studentstring = $course->students;
             notify(get_string('numattempts', 'quiz', $a));
         }
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// find out current groups mode
     if ($groupmode = groupmode($course, $cm)) {
         // Groups are being used
         if (!$download) {
             $currentgroup = setup_and_print_groups($course, $groupmode, $reporturlwithoptions);
         } else {
             $currentgroup = get_and_set_current_group($course, $groupmode);
         }
     } else {
         $currentgroup = get_and_set_current_group($course, $groupmode);
     }
     $hasfeedback = quiz_has_feedback($quiz->id) && $quiz->grade > 1.0E-7 && $quiz->sumgrades > 1.0E-7;
     if ($pagesize < 1) {
         $pagesize = 10;
     }
     // Now check if asked download of data
     if ($download) {
         $filename = clean_filename("{$course->shortname} " . format_string($quiz->name, true));
         $sort = '';
     }
     // Define table columns
     $tablecolumns = array('checkbox', 'picture', 'fullname', 'timestart', 'timefinish', 'duration');
     $tableheaders = array(NULL, '', get_string('name'), get_string('startedon', 'quiz'), get_string('timecompleted', 'quiz'), get_string('attemptduration', 'quiz'));
     if ($quiz->grade and $quiz->sumgrades) {
         $tablecolumns[] = 'sumgrades';
         $tableheaders[] = get_string('grade', 'quiz') . '/' . $quiz->grade;
     }
     if ($detailedmarks) {
         // we want to display marks for all questions
         // Start by getting all questions
         $questionlist = quiz_questions_in_quiz($quiz->questions);
         $questionids = explode(',', $questionlist);
         $sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance" . "  FROM {$CFG->prefix}question q," . "       {$CFG->prefix}quiz_question_instances i" . " WHERE i.quiz = '{$quiz->id}' AND q.id = i.question" . "   AND q.id IN ({$questionlist})";
         if (!($questions = get_records_sql($sql))) {
             error('No questions found');
         }
         $number = 1;
         foreach ($questionids as $key => $id) {
             if ($questions[$id]->length) {
//.........这里部分代码省略.........
开发者ID:veritech,项目名称:pare-project,代码行数:101,代码来源:report.php

示例10: print_error

    } else {
        $success = false;
    }
}
if (!$success) {
    print_error('errorprocessingresponses', 'question', $attemptobj->attempt_url(0, $page));
}
/// Log the end of this attempt.
add_to_log($attemptobj->get_courseid(), 'quiz', 'close attempt', 'review.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Update the quiz attempt record.
$attempt->timemodified = $timenow;
$attempt->timefinish = $timenow;
$DB->update_record('quiz_attempts', $attempt);
if (!$attempt->preview) {
    /// Record this user's best grade (if this is not a preview).
    quiz_save_best_grade($attemptobj->get_quiz());
    /// Send any notification emails (if this is not a preview).
    $attemptobj->quiz_send_notification_emails();
}
/// Clear the password check flag in the session.
$accessmanager = $attemptobj->get_access_manager($timenow);
$accessmanager->clear_password_access();
/// Trigger event
$eventdata = new stdClass();
$eventdata->component = 'mod_quiz';
$eventdata->course = $attemptobj->get_courseid();
$eventdata->quiz = $attemptobj->get_quizid();
$eventdata->cm = $attemptobj->get_cmid();
$eventdata->user = $USER;
$eventdata->attempt = $attemptobj->get_attemptid();
events_trigger('quiz_attempt_processed', $eventdata);
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:processattempt.php

示例11: process_comment

 /**
  * Process a manual comment for a question in this attempt.
  * @param $questionid
  * @param integer $questionid the question id
  * @param string $comment the new comment from the teacher.
  * @param mixed $grade the grade the teacher assigned, or '' to not change the grade.
  * @return mixed true on success, a string error message if a problem is detected
  *         (for example score out of range).
  */
 public function process_comment($questionid, $comment, $commentformat, $grade)
 {
     // I am not sure it is a good idea to have update methods here - this
     // class is only about getting data out of the question engine, and
     // helping to display it, apart from this.
     $this->ensure_question_loaded($questionid);
     $this->ensure_state_loaded($questionid);
     $state = $this->states[$questionid];
     $error = question_process_comment($this->questions[$questionid], $state, $this->attempt, $comment, $commentformat, $grade);
     // If the state was update (successfully), save the changes.
     if (!is_string($error) && $state->changed) {
         if (!save_question_session($this->questions[$questionid], $state)) {
             $error = get_string('errorudpatingquestionsession', 'quiz');
         }
         if (!quiz_save_best_grade($this->quiz, $this->attempt->userid)) {
             $error = get_string('errorudpatingbestgrade', 'quiz');
         }
     }
     return $error;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:29,代码来源:attemptlib.php

示例12: process_comment

 public function process_comment($questionid, $comment, $grade)
 {
     $this->ensure_question_loaded($questionid);
     $this->ensure_state_loaded($questionid);
     $state = $this->states[$questionid];
     $error = question_process_comment($this->questions[$questionid], $state, $this->attempt, $comment, $grade);
     // If the state was update (successfully), save the changes.
     if (!is_string($error) && $state->changed) {
         if (!save_question_session($this->questions[$questionid], $state)) {
             $error = get_string('errorudpatingquestionsession', 'quiz');
         }
         if (!quiz_save_best_grade($this->quiz, $this->attempt->userid)) {
             $error = get_string('errorudpatingbestgrade', 'quiz');
         }
     }
     return $error;
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:17,代码来源:attemptlib.php

示例13: evaluate_quiz


//.........这里部分代码省略.........
        mtrace('Obtained USERID value: ' . $userid . " OK. <BR/>");
        $quiz = get_quiz($acode);
        $attempts = quiz_get_user_attempts($quiz->id, $userid, 'all', true);
        mtrace("Searching quiz... Success." . "<BR/>");
        $uniqueid = get_uniqueid($acode);
        mtrace('Obtained uniqueid: OK. <BR/>');
        $timestamp = get_timestamp($acode);
        mtrace('Obtained timestamp: OK. <BR/>');
        if (!get_record('quiz_attempts', 'uniqueid', $uniqueid)) {
            $newattempt = true;
        } else {
            $newattempt = false;
            mtrace("User {$userid} had opened this attempt already.");
        }
        $attemptnumber = 1;
        if ($newattempt == false) {
            mtrace('Obtaining user attempt...<BR/>');
            set_attempt_unfinished($uniqueid);
            $attempt = quiz_get_user_attempt_unfinished($quiz->id, $userid);
        } elseif ($newattempt == true) {
            mtrace('Creating new attempt...<BR/>');
            $attempt = create_new_attempt($quiz, $attemptnumber, $userid, $acode, $uniqueid, $timestamp);
            // Save the attempt
            if (!insert_record('quiz_attempts', $attempt)) {
                throw new EvaluationError(get_string('ErrorCouldNotCreateAttempt', 'blended'), EvaluationError::CREATE_QUIZ_ATTEMPT_ERROR);
            }
            // Actualizamos el estado de las imágenes para indicar que ya está creado un nuevo attempt
            update_images_status($acode, $jobid);
        }
        update_question_attempts($uniqueid);
        // /*
        mtrace('<BR>Getting questions and question options... ');
        $questions = get_questions($attempt, $quiz);
        if (!get_question_options($questions)) {
            error('Could not load question options');
        }
        mtrace('Success! <BR>');
        //	print ("<BR>He obtenido questions: ");
        //print_object($questions);
        $lastattemptid = false;
        //	 if ($attempt->attempt > 1 and $quiz->attemptonlast and !$attempt->preview) {
        // Find the previous attempt
        //      if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) {
        //        error('Could not find previous attempt to build on');
        //  }
        //}
        //print ('He obtenido lastattemptid');
        mtrace('Getting question states... ');
        if (!($states = get_question_states($questions, $quiz, $attempt, $lastattemptid))) {
            error('Could not restore question sessions');
        }
        mtrace('Success! <BR>');
        mtrace('Getting responses... <BR>');
        $responses = get_responses($acode, $jobid, $attempt);
        //print('Estas son las responses:');
        //print_object($responses);
        //$timestamp=time();
        $event = 8;
        $actions = question_extract_responses($questions, $responses, $event);
        $questionids = get_questionids($acode);
        //	print $questionids;
        $questionidarray = explode(',', $questionids);
        $success = true;
        mtrace('<BR> Processing responses and saving session... ');
        foreach ($questionidarray as $i) {
            if (!isset($actions[$i])) {
                $actions[$i]->responses = array('' => '');
                $actions[$i]->event = QUESTION_EVENTOPEN;
            }
            $actions[$i]->timestamp = $timestamp;
            if (question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt)) {
                save_question_session($questions[$i], $states[$i]);
            } else {
                $success = false;
            }
        }
        mtrace('Success! <BR>');
        // Set the attempt to be finished
        $timestamp = time();
        //$attempt->timefinish = $timestamp;
        // Update the quiz attempt and the overall grade for the quiz
        mtrace('<BR> Finishing the attempt... ');
        // print_object ($attempt);
        if (set_field('quiz_attempts', 'timefinish', $timestamp, 'uniqueid', $uniqueid) == false) {
            throw new EvaluationError('Unable to finish the quiz attempt!', EvaluationError::FINISH_QUIZ_ATTEMPT_ERROR);
        }
        mtrace('Success! <BR>');
        if ($attempt->attempt > 1 || $attempt->timefinish > 0 and !$attempt->preview) {
            mtrace('<BR> Saving quiz grade... ');
            quiz_save_best_grade($quiz, $userid);
        }
        mtrace('Success! <BR>');
        // */
        mtrace("Process Done. <BR><BR>");
        mtrace("<center> Your quiz has been succesfully evaluated!! </center>");
    } catch (EvaluationError $e) {
        throw $e;
    }
    return;
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:101,代码来源:evaluationlib.php

示例14: quiz_delete_attempt

/**
 * Delete a quiz attempt.
 * @param mixed $attempt an integer attempt id or an attempt object (row of the quiz_attempts table).
 * @param object $quiz the quiz object.
 */
function quiz_delete_attempt($attempt, $quiz)
{
    if (is_numeric($attempt)) {
        if (!($attempt = get_record('quiz_attempts', 'id', $attempt))) {
            return;
        }
    }
    if ($attempt->quiz != $quiz->id) {
        debugging("Trying to delete attempt {$attempt->id} which belongs to quiz {$attempt->quiz} " . "but was passed quiz {$quiz->id}.");
        return;
    }
    delete_records('quiz_attempts', 'id', $attempt->id);
    delete_attempt($attempt->uniqueid);
    // Search quiz_attempts for other instances by this user.
    // If none, then delete record for this quiz, this user from quiz_grades
    // else recalculate best grade
    $userid = $attempt->userid;
    if (!record_exists('quiz_attempts', 'userid', $userid, 'quiz', $quiz->id)) {
        delete_records('quiz_grades', 'userid', $userid, 'quiz', $quiz->id);
    } else {
        quiz_save_best_grade($quiz, $userid);
    }
    quiz_update_grades($quiz, $userid);
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:29,代码来源:locallib.php

示例15: process_finish

 public function process_finish($timestamp, $processsubmitted)
 {
     global $DB;
     $transaction = $DB->start_delegated_transaction();
     if ($processsubmitted) {
         $this->quba->process_all_actions($timestamp);
     }
     $this->quba->finish_all_questions($timestamp);
     question_engine::save_questions_usage_by_activity($this->quba);
     $this->attempt->timemodified = $timestamp;
     $this->attempt->timefinish = $timestamp;
     $this->attempt->sumgrades = $this->quba->get_total_mark();
     $this->attempt->state = self::FINISHED;
     $this->attempt->timecheckstate = null;
     $DB->update_record('quiz_attempts', $this->attempt);
     if (!$this->is_preview()) {
         quiz_save_best_grade($this->get_quiz(), $this->attempt->userid);
         // Trigger event.
         $this->fire_state_transition_event('\\mod_quiz\\event\\attempt_submitted', $timestamp);
         // Tell any access rules that care that the attempt is over.
         $this->get_access_manager($timestamp)->current_attempt_finished();
     }
     $transaction->allow_commit();
 }
开发者ID:elie89,项目名称:moodle,代码行数:24,代码来源:attemptlib.php


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