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


PHP WooThemes_Sensei_Utils::sensei_add_answer_notes方法代码示例

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


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

示例1: process_grading

 public function process_grading()
 {
     // NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry
     if (isset($_POST['sensei_manual_grade']) && isset($_GET['quiz_id'])) {
         //			error_log( __CLASS__ . ':' . __FUNCTION__ . ':' . print_r($_POST, true));
         $quiz_id = $_GET['quiz_id'];
         $user_id = $_GET['user'];
         $verify_nonce = wp_verify_nonce($_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading');
         if ($verify_nonce && $quiz_id == $_POST['sensei_manual_grade']) {
             $questions = WooThemes_Sensei_Utils::sensei_get_quiz_questions($quiz_id);
             $quiz_grade = 0;
             $count = 0;
             $quiz_grade_total = $_POST['quiz_grade_total'];
             foreach ($questions as $question) {
                 ++$count;
                 $question_id = $question->ID;
                 if (isset($_POST['question_' . $question_id])) {
                     $correct = false;
                     $question_grade = 0;
                     $question_total_grade = $_POST['question_total_grade'];
                     if ($_POST['question_' . $question_id] == 'right') {
                         $correct = true;
                         $question_grade = $_POST['question_' . $question_id . '_grade'];
                     }
                     $activity_logged = WooThemes_Sensei_Utils::sensei_grade_question($question_id, $question_grade, $user_id);
                     $quiz_grade += $question_grade;
                 } else {
                     WooThemes_Sensei_Utils::sensei_delete_question_grade($question_id);
                 }
                 // WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), but
                 // as an answer note is not direct post_content it won't have slashes removed, so we need to do it
                 $answer_notes = wp_unslash($_POST['question_' . $question_id . '_notes']);
                 if (!$answer_notes || $answer_notes == '') {
                     $answer_notes = '';
                 }
                 WooThemes_Sensei_Utils::sensei_add_answer_notes($question_id, $user_id, $answer_notes);
             }
             if ($_POST['all_questions_graded'] == 'yes') {
                 $grade = abs(round(doubleval($quiz_grade) * 100 / $quiz_grade_total, 2));
                 $activity_logged = WooThemes_Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id);
                 // Duplicating what Frontend->sensei_complete_quiz() does
                 $quiz_lesson_id = absint(get_post_meta($quiz_id, '_quiz_lesson', true));
                 $pass_required = get_post_meta($quiz_id, '_pass_required', true);
                 $quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
                 $lesson_metadata = array();
                 if ($pass_required) {
                     // Student has reached the pass mark and lesson is complete
                     if ($quiz_passmark <= $grade) {
                         $lesson_status = 'passed';
                     } else {
                         $lesson_status = 'failed';
                     }
                     // End If Statement
                 } else {
                     $lesson_status = 'graded';
                 }
                 $lesson_metadata['grade'] = $grade;
                 // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above
                 WooThemes_Sensei_Utils::update_lesson_status($user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata);
                 switch ($lesson_status) {
                     case 'passed':
                     case 'graded':
                         do_action('sensei_user_lesson_end', $user_id, $quiz_lesson_id);
                         break;
                 }
             }
             if (isset($_POST['sensei_grade_next_learner']) && strlen($_POST['sensei_grade_next_learner']) > 0) {
                 $load_url = add_query_arg(array('message' => 'graded'));
             } elseif (isset($_POST['_wp_http_referer'])) {
                 $load_url = add_query_arg(array('message' => 'graded'), $_POST['_wp_http_referer']);
             } else {
                 $load_url = add_query_arg(array('message' => 'graded'));
             }
             wp_safe_redirect($load_url);
             exit;
         }
     }
 }
开发者ID:AlecBeltrami,项目名称:sensei,代码行数:78,代码来源:class-woothemes-sensei-grading.php


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