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


PHP quiz_update_open_attempts函数代码示例

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


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

示例1: xmldb_quiz_upgrade


//.........这里部分代码省略.........
        // Correct any wrong values.
        $DB->set_field('quiz', 'questiondecimalpoints', -1, array('questiondecimalpoints' => -2));

        // Quiz savepoint reached.
        upgrade_mod_savepoint(true, 2012061703, 'quiz');
    }

    if ($oldversion < 2012100801) {

        // Define field timecheckstate to be added to quiz_attempts
        $table = new xmldb_table('quiz_attempts');
        $field = new xmldb_field('timecheckstate', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'timemodified');

        // Conditionally launch add field timecheckstate
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        // Define index state-timecheckstate (not unique) to be added to quiz_attempts
        $table = new xmldb_table('quiz_attempts');
        $index = new xmldb_index('state-timecheckstate', XMLDB_INDEX_NOTUNIQUE, array('state', 'timecheckstate'));

        // Conditionally launch add index state-timecheckstate
        if (!$dbman->index_exists($table, $index)) {
            $dbman->add_index($table, $index);
        }

        // Overdue cron no longer needs these
        unset_config('overduelastrun', 'quiz');
        unset_config('overduedoneto', 'quiz');

        // Update timecheckstate on all open attempts
        require_once($CFG->dirroot . '/mod/quiz/locallib.php');
        quiz_update_open_attempts(array());

        // quiz savepoint reached
        upgrade_mod_savepoint(true, 2012100801, 'quiz');
    }

    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this

    if ($oldversion < 2013031900) {
        // Quiz manual grading UI should be controlled by mod/quiz:grade, not :viewreports.
        $DB->set_field('quiz_reports', 'capability', 'mod/quiz:grade', array('name' => 'grading'));

        // Mod quiz savepoint reached.
        upgrade_mod_savepoint(true, 2013031900, 'quiz');
    }

    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.


    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.

    if ($oldversion < 2014011300) {

        // Define key quiz (foreign) to be dropped form quiz_question_instances.
        $table = new xmldb_table('quiz_question_instances');
        $key = new xmldb_key('quiz', XMLDB_KEY_FOREIGN, array('quiz'), 'quiz', array('id'));

        // Launch drop key quiz.
        $dbman->drop_key($table, $key);
开发者ID:rwijaya,项目名称:moodle,代码行数:66,代码来源:upgrade.php

示例2: unset

            } else {
                unset($fromform->id);
                $fromform->id = $DB->insert_record('quiz_overrides', $fromform);
                // Determine which override created event to fire.
                $params['objectid'] = $fromform->id;
                if (!$groupmode) {
                    $params['relateduserid'] = $fromform->userid;
                    $event = \mod_quiz\event\user_override_created::create($params);
                } else {
                    $params['other']['groupid'] = $fromform->groupid;
                    $event = \mod_quiz\event\group_override_created::create($params);
                }
                // Trigger the override created event.
                $event->trigger();
            }
            quiz_update_open_attempts(array('quizid' => $quiz->id));
            quiz_update_events($quiz, $fromform);
            if (!empty($fromform->submitbutton)) {
                redirect($overridelisturl);
            }
            // The user pressed the 'again' button, so redirect back to this page.
            $url->remove_params('cmid');
            $url->param('action', 'duplicate');
            $url->param('id', $fromform->id);
            redirect($url);
        }
    }
}
// Print the form.
$pagetitle = get_string('editoverride', 'quiz');
$PAGE->navbar->add($pagetitle);
开发者ID:pzhu2004,项目名称:moodle,代码行数:31,代码来源:overrideedit.php

示例3: quiz_groups_members_removed_handler

/**
 * Handle groups_members_removed event
 *
 * @param object $event the event object.
 */
function quiz_groups_members_removed_handler($event) {
    if ($event->userid == 0) {
        quiz_update_open_attempts(array('courseid'=>$event->courseid));
    } else {
        quiz_update_open_attempts(array('courseid'=>$event->courseid, 'userid'=>$event->userid));
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:12,代码来源:locallib.php

示例4: quiz_groups_members_removed_handler

/**
 * Handle groups_members_removed event
 *
 * @param object $event the event object.
 * @deprecated since 2.6, see {@link \mod_quiz\group_observers::group_member_removed()}.
 */
function quiz_groups_members_removed_handler($event) {
    debugging('quiz_groups_members_removed_handler() is deprecated, please use ' .
        '\mod_quiz\group_observers::group_member_removed() instead.', DEBUG_DEVELOPER);
    if ($event->userid == 0) {
        quiz_update_open_attempts(array('courseid'=>$event->courseid));
    } else {
        quiz_update_open_attempts(array('courseid'=>$event->courseid, 'userid'=>$event->userid));
    }
}
开发者ID:rwijaya,项目名称:moodle,代码行数:15,代码来源:locallib.php

示例5: quiz_update_instance

/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param object $quiz the data that came from the form.
 * @return mixed true on success, false or a string error message on failure.
 */
function quiz_update_instance($quiz, $mform)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/quiz/locallib.php';
    // Process the options from the form.
    $result = quiz_process_options($quiz);
    if ($result && is_string($result)) {
        return $result;
    }
    // Get the current value, so we can see what changed.
    $oldquiz = $DB->get_record('quiz', array('id' => $quiz->instance));
    // We need two values from the existing DB record that are not in the form,
    // in some of the function calls below.
    $quiz->sumgrades = $oldquiz->sumgrades;
    $quiz->grade = $oldquiz->grade;
    // Repaginate, if asked to.
    if (!$quiz->shufflequestions && !empty($quiz->repaginatenow)) {
        $quiz->questions = quiz_repaginate(quiz_clean_layout($oldquiz->questions, true), $quiz->questionsperpage);
    }
    unset($quiz->repaginatenow);
    // Update the database.
    $quiz->id = $quiz->instance;
    $DB->update_record('quiz', $quiz);
    // Do the processing required after an add or an update.
    quiz_after_add_or_update($quiz);
    if ($oldquiz->grademethod != $quiz->grademethod) {
        quiz_update_all_final_grades($quiz);
        quiz_update_grades($quiz);
    }
    $quizdateschanged = $oldquiz->timelimit != $quiz->timelimit || $oldquiz->timeclose != $quiz->timeclose || $oldquiz->graceperiod != $quiz->graceperiod;
    if ($quizdateschanged) {
        quiz_update_open_attempts(array('quizid' => $quiz->id));
    }
    // Delete any previous preview attempts.
    quiz_delete_previews($quiz);
    return true;
}
开发者ID:achocoza,项目名称:moodle26,代码行数:45,代码来源:lib.php

示例6: xmldb_quiz_upgrade


//.........这里部分代码省略.........
    if ($oldversion < 2012061703) {
        // MDL-34702 the questiondecimalpoints column was created with default -2
        // when it should have been -1, and no-one has noticed in the last 2+ years!
        // Changing the default of field questiondecimalpoints on table quiz to -1.
        $table = new xmldb_table('quiz');
        $field = new xmldb_field('questiondecimalpoints', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '-1', 'decimalpoints');
        // Launch change of default for field questiondecimalpoints.
        $dbman->change_field_default($table, $field);
        // Correct any wrong values.
        $DB->set_field('quiz', 'questiondecimalpoints', -1, array('questiondecimalpoints' => -2));
        // Quiz savepoint reached.
        upgrade_mod_savepoint(true, 2012061703, 'quiz');
    }
    if ($oldversion < 2012100801) {
        // Define field timecheckstate to be added to quiz_attempts
        $table = new xmldb_table('quiz_attempts');
        $field = new xmldb_field('timecheckstate', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'timemodified');
        // Conditionally launch add field timecheckstate
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        // Define index state-timecheckstate (not unique) to be added to quiz_attempts
        $table = new xmldb_table('quiz_attempts');
        $index = new xmldb_index('state-timecheckstate', XMLDB_INDEX_NOTUNIQUE, array('state', 'timecheckstate'));
        // Conditionally launch add index state-timecheckstate
        if (!$dbman->index_exists($table, $index)) {
            $dbman->add_index($table, $index);
        }
        // Overdue cron no longer needs these
        unset_config('overduelastrun', 'quiz');
        unset_config('overduedoneto', 'quiz');
        // Update timecheckstate on all open attempts
        require_once $CFG->dirroot . '/mod/quiz/locallib.php';
        quiz_update_open_attempts(array());
        // quiz savepoint reached
        upgrade_mod_savepoint(true, 2012100801, 'quiz');
    }
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2013031900) {
        // Quiz manual grading UI should be controlled by mod/quiz:grade, not :viewreports.
        $DB->set_field('quiz_reports', 'capability', 'mod/quiz:grade', array('name' => 'grading'));
        // Mod quiz savepoint reached.
        upgrade_mod_savepoint(true, 2013031900, 'quiz');
    }
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2014011300) {
        // Define key quiz (foreign) to be dropped form quiz_question_instances.
        $table = new xmldb_table('quiz_question_instances');
        $key = new xmldb_key('quiz', XMLDB_KEY_FOREIGN, array('quiz'), 'quiz', array('id'));
        // Launch drop key quiz.
        $dbman->drop_key($table, $key);
        // Quiz savepoint reached.
        upgrade_mod_savepoint(true, 2014011300, 'quiz');
    }
    if ($oldversion < 2014011301) {
        // Rename field quiz on table quiz_question_instances to quizid.
        $table = new xmldb_table('quiz_question_instances');
        $field = new xmldb_field('quiz', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'id');
        // Launch rename field quiz.
        $dbman->rename_field($table, $field, 'quizid');
        // Quiz savepoint reached.
        upgrade_mod_savepoint(true, 2014011301, 'quiz');
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:67,代码来源:upgrade.php

示例7: test_group_event_handlers

    /**
     * Test the group event handlers
     */
    public function test_group_event_handlers() {
        global $DB,$CFG;

        $this->resetAfterTest();

        $this->setAdminUser();

        // Setup course, user and groups

        $course = $this->getDataGenerator()->create_course();
        $user1 = $this->getDataGenerator()->create_user();
        $studentrole = $DB->get_record('role', array('shortname'=>'student'));
        $this->assertNotEmpty($studentrole);
        $this->assertTrue(enrol_try_internal_enrol($course->id, $user1->id, $studentrole->id));
        $group1 = $this->getDataGenerator()->create_group(array('courseid'=>$course->id));
        $group2 = $this->getDataGenerator()->create_group(array('courseid'=>$course->id));
        $this->assertTrue(groups_add_member($group1, $user1));
        $this->assertTrue(groups_add_member($group2, $user1));

        $uniqueid = 0;

        $quiz_generator = $this->getDataGenerator()->get_plugin_generator('mod_quiz');

        $quiz = $quiz_generator->create_instance(array('course'=>$course->id, 'timeclose'=>1200, 'timelimit'=>0));

        // add a group1 override
        $DB->insert_record('quiz_overrides', array('quiz'=>$quiz->id, 'groupid'=>$group1->id, 'timeclose'=>1300, 'timelimit'=>null));

        // add an attempt
        $attemptid = $DB->insert_record('quiz_attempts', array('quiz'=>$quiz->id, 'userid'=>$user1->id, 'state'=>'inprogress', 'timestart'=>100, 'timecheckstate'=>0, 'layout'=>'', 'uniqueid'=>$uniqueid++));

        // update timecheckstate
        quiz_update_open_attempts(array('quizid'=>$quiz->id));
        $this->assertEquals(1300, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // remove from group
        $this->assertTrue(groups_remove_member($group1, $user1));
        $this->assertEquals(1200, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // add back to group
        $this->assertTrue(groups_add_member($group1, $user1));
        $this->assertEquals(1300, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // delete group
        groups_delete_group($group1);
        $this->assertEquals(1200, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));
        $this->assertEquals(0, $DB->count_records('quiz_overrides', array('quiz'=>$quiz->id)));

        // add a group2 override
        $DB->insert_record('quiz_overrides', array('quiz'=>$quiz->id, 'groupid'=>$group2->id, 'timeclose'=>1400, 'timelimit'=>null));
        quiz_update_open_attempts(array('quizid'=>$quiz->id));
        $this->assertEquals(1400, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // delete user1 from all groups
        groups_delete_group_members($course->id, $user1->id);
        $this->assertEquals(1200, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // add back to group2
        $this->assertTrue(groups_add_member($group2, $user1));
        $this->assertEquals(1400, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));

        // delete everyone from all groups
        groups_delete_group_members($course->id);
        $this->assertEquals(1200, $DB->get_field('quiz_attempts', 'timecheckstate', array('id'=>$attemptid)));
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:68,代码来源:attempts_test.php

示例8: group_member_removed

 /**
  * A group member was deleted.
  *
  * @param \core\event\base $event The event.
  * @return void
  */
 public static function group_member_removed($event)
 {
     if (!empty(self::$resetinprogress)) {
         // We will take care of that once the course reset ends.
         return;
     }
     quiz_update_open_attempts(array('userid' => $event->relateduserid, 'groupid' => $event->objectid));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:group_observers.php


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