Esempio n. 1
0
 /**
  * Grade question automatically
  *
  * This function checks the question typ and then grades it accordingly.
  *
  * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
  *
  * @param integer $question_id
  * @param string $question_type of the standard Sensei question types
  * @param string $answer
  * @param int $user_id
  *
  * @return int $question_grade
  */
 public static function sensei_grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0)
 {
     return WooThemes_Sensei_Grading::grade_question_auto($question_id, $question_type, $answer, $user_id);
 }
    public function add_grading_notices()
    {
        global $wpdb, $woothemes_sensei;
        if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) {
            if ('graded' == $_GET['message']) {
                $user_id = $_GET['user'];
                $quiz_id = $_GET['quiz_id'];
                /* 				echo "<pre>";
                				print_r(get_user_meta($user_id,'_grading_notes_history',true));
                				echo "</pre>"; */
                //using the quiz id, get the module id.
                $lesson_id = $woothemes_sensei->quiz->get_lesson_id($quiz_id);
                $course_id = get_post_meta($lesson_id, '_lesson_course', true);
                $module = get_the_terms($lesson_id, 'module');
                $module_id = $module[0]->term_id;
                $user_info = get_userdata($user_id);
                $user_email = $user_info->user_email;
                $results = $wpdb->get_results('SELECT Id FROM _isContact WHERE meta_field = "Email" AND meta_value = "' . $user_email . '"', OBJECT);
                $contact = $results[0];
                $cid = $contact->Id;
                //$shortcode = "[i4w_achievegoal cid='".$cid."' callname='make".$module_id."online']";
                //echo do_shortcode($shortcode);
                //create a function that will process infusionft apit
                call_infusion($cid, $module_id);
                //Need to get all the lessons in the module, and retrieve their marks. If all 100%, then we tag.
                $module_progress = WooThemes_Sensei_Grading::calculate_user_module_progress_custom($user_id, $module_id, $course_id);
                $totally_competant = 'No';
                if ($module_progress < 100) {
                    $totally_competant = 'No';
                } else {
                    $totally_competant = 'Yes';
                    //add infusionsoft tag
                    call_infusion_complet_module($cid, $module_id);
                }
                $msg = array('updated', __('Quiz Graded Successfully! ' . $totally_competant . ' ' . $module_progress . '%', 'woothemes-sensei'));
            }
            ?>
			<div class="grading-notice <?php 
            echo $msg[0];
            ?>
">
				<p><?php 
            echo $msg[1];
            ?>
</p>
			</div>
			<?php 
        }
    }