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


PHP feedback_save_tmp_values函数代码示例

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


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

示例1: test_response_submitted_event

    /**
     * Tests for event response_submitted.
     */
    public function test_response_submitted_event() {
        global $USER, $DB;
        $this->resetAfterTest();
        $this->setUser($this->eventuser);

        // Create a temporary response, with anonymous set to yes.
        $response = new stdClass();
        $response->feedback = $this->eventcm->instance;
        $response->userid = $this->eventuser->id;
        $response->anonymous_response = FEEDBACK_ANONYMOUS_YES;
        $completedid = $DB->insert_record('feedback_completedtmp', $response);
        $completed = $DB->get_record('feedback_completedtmp', array('id' => $completedid), '*', MUST_EXIST);
        $value = new stdClass();
        $value->course_id = $this->eventcourse->id;
        $value->item = $this->eventfeedbackitem->id;
        $value->completed = $completedid;
        $value->value = 25; // User response value.
        $DB->insert_record('feedback_valuetmp', $value);

        // Save the feedback.
        $sink = $this->redirectEvents();
        $id = feedback_save_tmp_values($completed, false, $USER->id);
        $events = $sink->get_events();
        $event = array_pop($events); // Response submitted feedback event.
        $sink->close();

        // Validate event data. Feedback is anonymous.
        $this->assertInstanceOf('\mod_feedback\event\response_submitted', $event);
        $this->assertEquals($id, $event->objectid);
        $this->assertEquals($USER->id, $event->userid);
        $this->assertEquals($USER->id, $event->relateduserid);
        $this->assertEquals('feedback_completed', $event->objecttable);
        $this->assertEquals($this->eventcm->id, $event->other['cmid']);
        $this->assertEquals($this->eventcm->instance, $event->other['instanceid']);
        $this->assertEquals(FEEDBACK_ANONYMOUS_YES, $event->other['anonymous']);
        $this->setUser($this->eventuser);
        $this->assertFalse($event->can_view());
        $this->setAdminUser();
        $this->assertTrue($event->can_view());

        // Test legacy data.
        $this->assertEventLegacyLogData(null, $event);

        // Create a temporary response, with anonymous set to no.
        $response = new stdClass();
        $response->feedback = $this->eventcm->instance;
        $response->userid = $this->eventuser->id;
        $response->anonymous_response = FEEDBACK_ANONYMOUS_NO;
        $completedid = $DB->insert_record('feedback_completedtmp', $response);
        $completed = $DB->get_record('feedback_completedtmp', array('id' => $completedid), '*', MUST_EXIST);
        $value = new stdClass();
        $value->course_id = $this->eventcourse->id;
        $value->item = $this->eventfeedbackitem->id;
        $value->completed = $completedid;
        $value->value = 25; // User response value.
        $DB->insert_record('feedback_valuetmp', $value);

        // Save the feedback.
        $sink = $this->redirectEvents();
        feedback_save_tmp_values($completed, false, $USER->id);
        $events = $sink->get_events();
        $event = array_pop($events); // Response submitted feedback event.
        $sink->close();

        // Test legacy data.
        $arr = array($this->eventcourse->id, 'feedback', 'submit', 'view.php?id=' . $this->eventcm->id, $this->eventfeedback->id,
                     $this->eventfeedback->id, $USER->id);
        $this->assertEventLegacyLogData($arr, $event);

        // Test can_view().
        $this->assertTrue($event->can_view());
        $this->setAdminUser();
        $this->assertTrue($event->can_view());
        $this->assertEventContextNotUsed($event);
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:78,代码来源:events_test.php

示例2: array

        //arb changed from 0 to $USER->id
        //no strict anonymous feedbacks
        //if it is a guest taking it then I want to know that it was
        //a guest (at least in the data saved in the feedback tables)
        $userid = $USER->id;

        $params = array('id'=>$completedid);
        $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', $params);

        //fake saving for switchrole
        $is_switchrole = feedback_check_is_switchrole();
        if ($is_switchrole) {
            $savereturn = 'saved';
            feedback_delete_completedtmp($completedid);
        } else {
            $new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, false, $userid);
            if ($new_completed_id) {
                $savereturn = 'saved';
                feedback_send_email_anonym($cm, $feedback, $course, $userid);
                unset($SESSION->feedback->is_started);

            } else {
                $savereturn = 'failed';
            }
        }
    }

    if ($allbreaks = feedback_get_all_break_positions($feedback->id)) {
        if ($gopage <= 0) {
            $startposition = 0;
        } else {
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:complete_guest.php

示例3: feedback_get_current_completed

 //exists there any pagebreak, so there are values in the feedback_valuetmp
 $userid = $USER->id;
 //arb
 if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
     $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
 } else {
     $feedbackcompleted = false;
 }
 $feedbackcompletedtmp = get_record('feedback_completedtmp', 'id', $completedid);
 //fake saving for switchrole
 $is_switchrole = feedback_check_is_switchrole();
 if ($is_switchrole) {
     $savereturn = 'saved';
     feedback_delete_completedtmp($completedid);
 } else {
     if ($new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $userid)) {
         $savereturn = 'saved';
         if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
             add_to_log($course->id, 'feedback', 'submit', 'view.php?id=' . $cm->id, $feedback->id, $cm->id, $userid);
             feedback_send_email($cm, $feedback, $course, $userid);
         } else {
             feedback_send_email_anonym($cm, $feedback, $course, $userid);
         }
         //tracking the submit
         $multiple_count = null;
         $multiple_count->userid = $USER->id;
         $multiple_count->feedback = $feedback->id;
         $multiple_count->completed = $new_completed_id;
         $multiple_count->count = 1;
         insert_record('feedback_tracking', $multiple_count);
         unset($SESSION->feedback->is_started);
开发者ID:kai707,项目名称:ITSA-backup,代码行数:31,代码来源:complete.php

示例4: save_response

 /**
  * Saves the response
  *
  * The form data has already been stored in the temporary table in
  * {@link save_response_tmp()}. This function copies the values
  * from the temporary table to the completion table.
  * It is also responsible for sending email notifications when applicable.
  */
 public function save_response()
 {
     global $USER, $SESSION, $DB;
     $feedbackcompleted = $this->find_last_completed();
     $feedbackcompletedtmp = $this->get_current_completed_tmp();
     if (feedback_check_is_switchrole()) {
         // We do not actually save anything if the role is switched, just delete temporary values.
         $this->delete_completedtmp();
         return;
     }
     // Save values.
     $completedid = feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted);
     $this->completed = $DB->get_record('feedback_completed', array('id' => $completedid));
     // Send email.
     if ($this->feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
         feedback_send_email($this->cm, $this->feedback, $this->cm->get_course(), $USER);
     } else {
         feedback_send_email_anonym($this->cm, $this->feedback, $this->cm->get_course());
     }
     unset($SESSION->feedback->is_started);
     // Update completion state.
     $completion = new completion_info($this->cm->get_course());
     if (isloggedin() && !isguestuser() && $completion->is_enabled($this->cm) && $this->feedback->completionsubmit) {
         $completion->update_state($this->cm, COMPLETION_COMPLETE);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:34,代码来源:completion.php


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