本文整理汇总了PHP中WooThemes_Sensei_Utils::sensei_get_activity_value方法的典型用法代码示例。如果您正苦于以下问题:PHP WooThemes_Sensei_Utils::sensei_get_activity_value方法的具体用法?PHP WooThemes_Sensei_Utils::sensei_get_activity_value怎么用?PHP WooThemes_Sensei_Utils::sensei_get_activity_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WooThemes_Sensei_Utils
的用法示例。
在下文中一共展示了WooThemes_Sensei_Utils::sensei_get_activity_value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_type_custom_column_content
/**
* post_type_custom_column_content function.
*
* @access public
* @since 1.0.0
* @return void
*/
public function post_type_custom_column_content($column_name, $post_ID)
{
$user_id = get_post_meta($post_ID, $key = 'learner_id', true);
$course_id = get_post_meta($post_ID, $key = 'course_id', true);
$user = get_userdata($user_id);
$course = get_post($course_id);
$course_end_date = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_date'));
$certificate_hash = esc_html(substr(md5($course_id . $user_id), -8));
switch ($column_name) {
case "learner":
echo '<a href="' . add_query_arg(array('page' => 'sensei_analysis', 'user' => intval($user_id), 'course_id' => intval($course_id)), admin_url('edit.php?post_type=lesson')) . '">' . $user->user_login . '</a>';
break;
case "course":
echo '<a href="' . add_query_arg(array('page' => 'sensei_analysis', 'course_id' => intval($course_id)), admin_url('edit.php?post_type=lesson')) . '">' . $course->post_title . '</a>';
break;
case "date_completed":
echo $course_end_date;
break;
case "actions":
echo '<a href="' . add_query_arg(array('certificate' => '1', 'hash' => $certificate_hash), site_url()) . '" target="_blank">' . __('View Certificate', 'sensei-certificates') . '</a>';
break;
}
// End Switch Statement
}
开发者ID:bramburn,项目名称:sensei-certificates,代码行数:31,代码来源:class-woothemes-sensei-certificate-templates.php
示例2: display
/**
* Display output to the admin view
*
* This view is shown when grading a quiz for a single user in admin under grading
*
* @since 1.3.0
* @return html
*/
public function display()
{
// Get data for the user
//echo do_shortcode("[i4w_get_contactId]");
//die();
$questions = $this->build_data_array();
global $woothemes_sensei;
$count = 0;
$graded_count = 0;
$user_quiz_grade_total = 0;
$quiz_grade_total = 0;
$quiz_grade = 0;
$lesson_id = $this->lesson_id;
$user_id = $this->user_id;
?>
<form name="<?php
esc_attr_e('quiz_' . $this->quiz_id);
?>
" action="" method="post">
<?php
wp_nonce_field('sensei_manual_grading', '_wp_sensei_manual_grading_nonce');
?>
<input type="hidden" name="sensei_manual_grade" value="<?php
esc_attr_e($this->quiz_id);
?>
" />
<input type="hidden" name="sensei_grade_next_learner" value="<?php
esc_attr_e($this->user_id);
?>
" />
<div class="total_grade_display">
<span><?php
esc_attr_e(__('Grade:', 'woothemes-sensei'));
?>
</span>
<span class="total_grade_total"><?php
echo $user_quiz_grade_total;
?>
</span> / <span class="quiz_grade_total"><?php
echo $quiz_grade_total;
?>
</span> (<span class="total_grade_percent"><?php
echo $quiz_grade;
?>
</span>%)
</div>
<div class="buttons">
<input type="submit" value="<?php
esc_attr_e(__('Save', 'woothemes-sensei'));
?>
" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
<input type="button" value="<?php
esc_attr_e(__('Auto grade', 'woothemes-sensei'));
?>
" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
<input type="reset" value="<?php
esc_attr_e(__('Reset', 'woothemes-sensei'));
?>
" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
</div>
<div class="clear"></div><br/><?php
$lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID'));
$user_quiz_grade = get_comment_meta($lesson_status_id, 'grade', true);
$correct_answers = 0;
foreach ($questions as $question) {
$question_id = $question->ID;
++$count;
$type = false;
$type_name = '';
$type = Sensei()->question->get_question_type($question_id);
$question_answer_notes = $woothemes_sensei->quiz->get_user_question_feedback($lesson_id, $question_id, $user_id);
$question_grade_total = get_post_meta($question_id, '_question_grade', true);
if (!$question_grade_total || 0 == intval($question_grade_total)) {
$question_grade_total = 1;
}
$quiz_grade_total += $question_grade_total;
$right_answer = get_post_meta($question_id, '_question_right_answer', true);
$user_answer_content = $woothemes_sensei->quiz->get_user_question_answer($lesson_id, $question_id, $user_id);
$type_name = __('Multiple Choice', 'woothemes-sensei');
$grade_type = 'manual-grade';
switch ($type) {
case 'boolean':
$type_name = __('True/False', 'woothemes-sensei');
$right_answer = ucfirst($right_answer);
$user_answer_content = ucfirst($user_answer_content);
$grade_type = 'auto-grade';
break;
case 'multiple-choice':
$type_name = __('Multiple Choice', 'woothemes-sensei');
$grade_type = 'auto-grade';
break;
//.........这里部分代码省略.........
开发者ID:Ezyva2015,项目名称:opendooronline.com.au,代码行数:101,代码来源:class-woothemes-sensei-grading-user-quiz.php
示例3: sensei_get_user_quiz_answers
/**
* @deprecated use WooThemes_Sensei_Quiz::get_user_answers
* @param int $lesson_id
* @return array
*/
public function sensei_get_user_quiz_answers($lesson_id = 0)
{
global $current_user, $woothemes_sensei;
$user_answers = array();
if (0 < intval($lesson_id)) {
$lesson_quiz_questions = $woothemes_sensei->post_types->lesson->lesson_quiz_questions($lesson_id);
foreach ($lesson_quiz_questions as $question) {
$answer = maybe_unserialize(base64_decode(WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content'))));
$user_answers[$question->ID] = $answer;
}
}
return $user_answers;
}
示例4: user_started_lesson
/**
* Check if a user has started a lesson or not
*
* @since 1.7.0
* @param type $lesson_id
* @param type $user_id
* @return mixed false or comment_ID
*/
public static function user_started_lesson($lesson_id = 0, $user_id = 0)
{
if ($lesson_id) {
if (!$user_id) {
$user_id = get_current_user_id();
}
$user_lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID'));
if ($user_lesson_status_id) {
return $user_lesson_status_id;
}
}
return false;
}
示例5: sensei_update_users_certificate_data
/**
* sensei_update_users_certificate_data install user certificate data
* @since 1.0.0
* @param int $n number of items to iterate through
* @param int $offeset number to offset iteration by
* @return boolean
*/
function sensei_update_users_certificate_data($n = 5, $offset = 0)
{
$loop_ran = false;
// Calculate if this is the last page
if (0 == $offset) {
$current_page = 1;
} else {
$current_page = intval($offset / $n);
}
// End If Statement
$args_array = array('number' => $n, 'offset' => $offset, 'orderby' => 'ID', 'order' => 'DESC', 'fields' => 'all_with_meta');
$wp_user_update = new WP_User_Query($args_array);
$users = $wp_user_update->get_results();
$user_count = count_users();
$total_items = $user_count['total_users'];
$query_total = $wp_user_update->get_total();
$total_pages = intval($total_items / $n);
foreach ($users as $user_key => $user_item) {
$course_ids = WooThemes_Sensei_Utils::sensei_activity_ids(array('user_id' => $user_item->ID, 'type' => 'sensei_course_start'));
$posts_array = array();
if (0 < intval(count($course_ids))) {
$posts_array = Sensei()->course->course_query(-1, 'usercourses', $course_ids);
}
// End If Statement
foreach ($posts_array as $course_item) {
$course_end_date = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_item->ID, 'user_id' => $user_item->ID, 'type' => 'sensei_course_end', 'field' => 'comment_date'));
if (isset($course_end_date) && '' != $course_end_date) {
$args = array('post_type' => 'certificate', 'author' => $user_item->ID, 'meta_key' => 'course_id', 'meta_value' => $course_item->ID);
$query = new WP_Query($args);
if (!$query->have_posts()) {
// Insert custom post type
$cert_args = array('post_author' => intval($user_item->ID), 'post_title' => esc_html(substr(md5($course_item->ID . $user_item->ID), -8)), 'post_name' => esc_html(substr(md5($course_item->ID . $user_item->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_item->ID));
add_post_meta($post_id, 'learner_id', intval($user_item->ID));
add_post_meta($post_id, 'certificate_hash', esc_html(substr(md5($course_item->ID . $user_item->ID), -8)));
$loop_ran = true;
}
// End If Statement
}
// End If Statement
wp_reset_query();
}
// End If Statement
}
// End For Loop
}
// End For Loop
if ($current_page >= $total_pages) {
return true;
} else {
return false;
}
// End If Statement
}
示例6: display
/**
* display output to the admin view
* @since 1.3.0
* @return html
*/
public function display()
{
// Get data for the user
$questions = $this->build_data_array();
$count = 0;
$graded_count = 0;
$user_quiz_grade_total = 0;
$quiz_grade_total = 0;
$quiz_grade = 0;
?>
<form name="<?php
esc_attr_e('quiz_' . $this->quiz_id);
?>
" action="" method="post">
<?php
wp_nonce_field('sensei_manual_grading', '_wp_sensei_manual_grading_nonce');
?>
<input type="hidden" name="sensei_manual_grade" value="<?php
esc_attr_e($this->quiz_id);
?>
" />
<input type="hidden" name="sensei_grade_next_learner" value="<?php
esc_attr_e($this->user_id);
?>
" />
<div class="total_grade_display">
<span><?php
esc_attr_e(__('Grade:', 'woothemes-sensei'));
?>
</span>
<span class="total_grade_total"><?php
echo $user_quiz_grade_total;
?>
</span> / <span class="quiz_grade_total"><?php
echo $quiz_grade_total;
?>
</span> (<span class="total_grade_percent"><?php
echo $quiz_grade;
?>
</span>%)
</div>
<div class="buttons">
<input type="submit" value="<?php
esc_attr_e(__('Save', 'woothemes-sensei'));
?>
" class="grade-button button-primary" title="Saves grades as currently marked on this page" />
<input type="button" value="<?php
esc_attr_e(__('Auto grade', 'woothemes-sensei'));
?>
" class="autograde-button button-secondary" title="Where possible, automatically grades questions that have not yet been graded" />
<input type="reset" value="<?php
esc_attr_e(__('Reset', 'woothemes-sensei'));
?>
" class="reset-button button-secondary" title="Resets all questions to ungraded and total grade to 0" />
</div>
<div class="clear"></div><br/><?php
$lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $this->lesson_id, 'user_id' => $this->user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID'));
$user_quiz_grade = get_comment_meta($lesson_status_id, 'grade', true);
$correct_answers = 0;
foreach ($questions as $question) {
$question_id = $question->ID;
++$count;
$type = false;
$type_name = '';
$types = wp_get_post_terms($question_id, 'question-type');
foreach ($types as $t) {
$type = $t->name;
break;
}
if (!$type) {
$type = 'multiple-choice';
}
$user_answer = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $this->user_id, 'type' => 'sensei_user_answer'), true);
$question_answer_notes = WooThemes_Sensei_Utils::sensei_get_user_question_answer_notes($user_answer);
$question_grade_total = get_post_meta($question_id, '_question_grade', true);
if (!$question_grade_total || 0 == intval($question_grade_total)) {
$question_grade_total = 1;
}
$quiz_grade_total += $question_grade_total;
$right_answer = get_post_meta($question_id, '_question_right_answer', true);
$user_answer_content = maybe_unserialize(base64_decode($user_answer->comment_content));
$type_name = __('Multiple Choice', 'woothemes-sensei');
$grade_type = 'manual-grade';
switch ($type) {
case 'boolean':
$type_name = __('True/False', 'woothemes-sensei');
$right_answer = ucfirst($right_answer);
$user_answer_content = ucfirst($user_answer_content);
$grade_type = 'auto-grade';
break;
case 'multiple-choice':
$type_name = __('Multiple Choice', 'woothemes-sensei');
$grade_type = 'auto-grade';
break;
case 'gap-fill':
//.........这里部分代码省略.........