コード例 #1
0
 static function save_quiz_questions($post_id)
 {
     learn_press_debug($_POST);
     die;
     static $has_updated;
     $questions = isset($_POST[LP()->question_post_type]) ? $_POST[LP()->question_post_type] : null;
     if (!$questions) {
         return;
     }
     $postmeta = array();
     // prevent infinite loop with save_post action
     if ($has_updated) {
         return;
     }
     $has_updated = true;
     foreach ($questions as $question_id => $options) {
         $question = LP_Question::instance($question_id);
         if ($question) {
             $question_id = $question->save_post_action();
             if ($question_id) {
                 $postmeta[$question_id] = array('toggle' => $options['toggle']);
                 if (!empty($options['type'])) {
                     $post_data = get_post_meta($question_id, '_lpr_question', true);
                     $post_data['type'] = $options['type'];
                     update_post_meta($question_id, '_lpr_question', $post_data);
                 }
             }
         }
     }
     update_post_meta($post_id, '_lpr_quiz_questions', $postmeta);
 }
コード例 #2
0
 static function log()
 {
     if (LP_Settings::instance()->get('debug') != 'yes') {
         return;
     }
     if ($args = func_get_args()) {
         foreach ($args as $arg) {
             learn_press_debug($arg);
         }
     }
 }
コード例 #3
0
 /**
  * Store question data
  */
 function store()
 {
     $post_id = $this->id;
     $is_new = false;
     if ($post_id) {
         $post_id = wp_update_post(array('ID' => $post_id, 'post_title' => $this->get('post_title'), 'post_type' => LP()->question_post_type, 'post_status' => 'publish'));
     } else {
         $post_id = wp_insert_post(array('post_title' => $this->get('post_title'), 'post_type' => LP()->question_post_type, 'post_status' => 'publish'));
         $is_new = true;
     }
     learn_press_debug($_POST);
     if ($post_id) {
         $options = $this->get('options');
         $options['type'] = $this->get_type();
         $this->set('options', $options);
         update_post_meta($post_id, '_lpr_question', $this->get('options'));
         // update default mark
         if ($is_new) {
             update_post_meta($post_id, '_lpr_question_mark', 1);
         }
         $this->ID = $post_id;
     }
     return $post_id;
 }
コード例 #4
0
ファイル: debug.php プロジェクト: taibeo1905/LearnPress
function learn_press_head_head()
{
    learn_press_debug($_REQUEST, false);
}
コード例 #5
0
 function save_post_action()
 {
     if ($post_id = $this->id) {
         $post_data = isset($_POST[LP()->question_post_type]) ? $_POST[LP()->question_post_type] : array();
         $post_answers = array();
         //$post_explain = $post_data[$post_id]['explanation'];
         learn_press_debug($_POST);
         if (isset($post_data[$post_id]) && ($post_data = $post_data[$post_id])) {
             $post_args = array('ID' => $post_id, 'post_title' => $post_data['text'], 'post_type' => LP()->question_post_type);
             wp_update_post($post_args);
             $index = 0;
             foreach ($post_data['answer']['text'] as $k => $txt) {
                 if (!$txt) {
                     continue;
                 }
                 $post_answers[$index] = array('text' => $txt, 'is_true' => $post_data['answer']['is_true'][$k]);
                 $index++;
             }
         }
         $post_data['answer'] = $post_answers;
         $post_data['type'] = $this->get_type();
         //$post_data['explanation']  = $post_explain;
         update_post_meta($post_id, '_lpr_question', $post_data);
     }
     return intval($post_id);
 }
コード例 #6
0
 /**
  * Enroll this user to a course
  *
  * @param $course_id
  *
  * @return int|void
  * @throws Exception
  */
 function enroll($course_id)
 {
     if (!$this->can('enroll-course', $course_id)) {
         learn_press_add_notice(__('Sorry! You can not enroll this course. Please try again or contact site admin'), 'error');
         return;
     }
     global $wpdb;
     $inserted = 0;
     $check = apply_filters('learn_press_before_enroll_course', true, $this, $course_id);
     if (!$check) {
         return false;
     }
     if ($wpdb->insert($wpdb->learnpress_user_courses, array('user_id' => $this->id, 'course_id' => $course_id, 'start_time' => current_time('mysql'), 'status' => 'enrolled', 'end_time' => '0000-00-00 00:00:00', 'order_id' => $this->get_course_order($course_id)), array('%d', '%d', '%s', '%s', '%s'))) {
         $inserted = $wpdb->insert_id;
         do_action('learn_press_user_enrolled_course', $this, $course_id, $inserted);
     } else {
         learn_press_debug($wpdb);
         do_action('learn_press_user_enroll_course_failed', $this, $course_id, $inserted);
     }
     return $inserted;
 }
コード例 #7
0
        /**
         * Load lesson content
         */
        public static function load_lesson_content()
        {
            learn_press_debug($_REQUEST);
            global $post;
            $lesson_id = $_POST['lesson_id'];
            $title = get_the_title($lesson_id);
            $post = get_post($lesson_id);
            $content = $post->post_content;
            $content = apply_filters('the_content', $content);
            printf('<h3>%s</h3>
				%s
				<button class="complete-lesson-button">Complete Lesson</button>', $title, $content);
            die;
        }
コード例 #8
0
 public static function convert_question_type()
 {
     learn_press_debug($_POST);
     if (($from = learn_press_get_request('from')) && ($to = learn_press_get_request('to')) && ($question_id = learn_press_get_request('question_id'))) {
         do_action('learn_press_convert_question_type', $question_id, $from, $to);
         $question = LP_Question_Factory::get_question($question_id);
         learn_press_send_json(array('html' => $question->admin_interface(array('echo' => false)), 'icon' => $question->get_icon()));
     } else {
         throw new Exception(__('Convert question type must be specify the id, source and destination type', 'learn_press'));
     }
     die;
 }