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


PHP WooThemes_Sensei_Utils::sensei_log_activity方法代码示例

本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_log_activity方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_log_activity方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_log_activity怎么用?PHP WooThemes_Sensei_Utils::sensei_log_activity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WooThemes_Sensei_Utils的用法示例。


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

示例1: update_course_status

 /**
  * Sets the statuses for the Course
  *
  * @access public
  * @since  1.7.0
  * @param type $user_id
  * @param type $course_id
  * @param type $status
  * @param type $metadata
  * @return mixed false or comment_ID
  */
 public static function update_course_status($user_id, $course_id, $status = 'in-progress', $metadata = array())
 {
     $comment_id = false;
     if (!empty($status)) {
         $args = array('user_id' => $user_id, 'post_id' => $course_id, 'status' => $status, 'type' => 'sensei_course_status', 'action' => 'update', 'keep_time' => true);
         if ('in-progress' == $status) {
             unset($args['keep_time']);
             // Keep updating what's happened
         }
         $comment_id = WooThemes_Sensei_Utils::sensei_log_activity($args);
         if ($comment_id && !empty($metadata)) {
             foreach ($metadata as $key => $value) {
                 update_comment_meta($comment_id, $key, $value);
             }
         }
         do_action('sensei_course_status_updated', $status, $user_id, $course_id, $comment_id);
     }
     return $comment_id;
 }
开发者ID:grey-rsi,项目名称:sensei,代码行数:30,代码来源:class-woothemes-sensei-utils.php

示例2: generate_certificate_number

 /**
  * Generate unique certificate hash and save as comment.
  *
  * @access public
  * @since  1.0.0
  * @param  int $user_id arguments for queries
  * @param  int $course_id data to post
  * @return void
  */
 public function generate_certificate_number($user_id = 0, $course_id = 0)
 {
     if (!$user_id || !$course_id) {
         return;
     }
     $cert_args = array('post_author' => intval($user_id), 'post_title' => esc_html(substr(md5($course_id . $user_id), -8)), 'post_name' => esc_html(substr(md5($course_id . $user_id), -8)), 'post_type' => 'certificate', 'post_status' => 'publish');
     $post_id = wp_insert_post($cert_args, $wp_error = false);
     if (!is_wp_error($post_id)) {
         add_post_meta($post_id, 'course_id', intval($course_id));
         add_post_meta($post_id, 'learner_id', intval($user_id));
         add_post_meta($post_id, 'certificate_hash', esc_html(substr(md5($course_id . $user_id), -8)));
         $data = array('post_id' => intval($post_id), 'data' => esc_html(substr(md5($course_id . $user_id), -8)), 'type' => 'sensei_certificate', 'user_id' => intval($user_id));
         WooThemes_Sensei_Utils::sensei_log_activity($data);
     }
 }
开发者ID:bramburn,项目名称:sensei-certificates,代码行数:24,代码来源:class-woothemes-sensei-certificates.php

示例3: testGetUserQuestionFeedback

 /**
  * This test Sensei()->quiz->get_user_question_feedback
  */
 public function testGetUserQuestionFeedback()
 {
     global $woothemes_sensei;
     // does this function add_user_data exist?
     $this->assertTrue(method_exists($woothemes_sensei->quiz, 'get_user_question_feedback'), 'The utils class function `get_user_question_feedback` does not exist ');
     // does it return false for invalid data
     $invalid_data_message = 'This get_user_question_feedback function does not check false data correctly';
     $this->assertFalse($woothemes_sensei->quiz->get_user_question_feedback('', '', ''), $invalid_data_message);
     $this->assertFalse($woothemes_sensei->quiz->get_user_question_feedback(' ', ' ', ' '), $invalid_data_message);
     $this->assertFalse($woothemes_sensei->quiz->get_user_question_feedback(-2, -3, -1), $invalid_data_message);
     $this->assertFalse($woothemes_sensei->quiz->get_user_question_feedback(3000, 5000, 5000), $invalid_data_message);
     // setup the next assertion
     $test_user_id = wp_create_user('studentQuestionFeedback', 'studentQuestionFeedback', 'studQFeedback@test.com');
     $test_lesson_id = $this->factory->get_random_lesson_id();
     $test_quiz_id = $woothemes_sensei->lesson->lesson_quizzes($test_lesson_id);
     $test_user_answers_feedback = $this->factory->generate_user_answers_feedback($test_quiz_id);
     WooThemes_Sensei_Utils::sensei_start_lesson($test_lesson_id, $test_user_id);
     $woothemes_sensei->quiz->save_user_answers_feedback($test_user_answers_feedback, $test_lesson_id, $test_user_id);
     $test_question_id = array_rand($test_user_answers_feedback);
     $retrieved_grade = $woothemes_sensei->quiz->get_user_question_feedback($test_lesson_id, $test_question_id, $test_user_id);
     //test if the the question grade can be retrieved
     $this->assertEquals($test_user_answers_feedback[$test_question_id], $retrieved_grade, 'The feedback retrieved is not equal to the one that was set for this question ID');
     //setup the next assertion for backwards compatibility.
     $transient_key = 'sensei_answers_feedback_' . $test_user_id . '_' . $test_lesson_id;
     delete_transient($transient_key);
     WooThemes_Sensei_Utils::delete_user_data('quiz_answers_feedback', $test_lesson_id, $test_user_id);
     $random_question_id = array_rand($test_user_answers_feedback);
     $old_data_args = array('post_id' => $random_question_id, 'user_id' => $test_user_id, 'type' => 'sensei_user_answer', 'data' => 'test answer feedback');
     $old_data_activity_id = WooThemes_Sensei_Utils::sensei_log_activity($old_data_args);
     update_comment_meta($old_data_activity_id, 'answer_note', base64_encode('Sensei sample feedback'));
     $retrieved_feedback = $woothemes_sensei->quiz->get_user_question_feedback($test_lesson_id, $random_question_id, $test_user_id);
     // Does the fall back to 1.7.3 data work?
     $this->assertEquals('Sensei sample feedback', $retrieved_feedback, 'The get user feedback does not fall back the old data');
 }
开发者ID:ragulka,项目名称:sensei,代码行数:37,代码来源:test-class-quiz.php


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