Example #1
0
 function auto_share($userid, $quizid, $badge = FALSE, $badge_name = FALSE)
 {
     $auth = $this->auth($userid);
     $row1 = $this->db->query("SELECT point, amount FROM score WHERE user_id='{$userid}' AND quiz_id='{$quizid}' LIMIT 1")->row();
     $row2 = $this->db->query("SELECT share_created, share_took, share_onehundred, share_badge FROM user WHERE username='******' LIMIT 1")->row();
     $send = FALSE;
     if ($badge == FALSE) {
         if ($row1->point > $row1->amount && $row2->share_created == 1) {
             $tweet = 'I just created the quiz \'' . get_title($quizid, FALSE) . '\' on @OneExtraLap! Come & take it! ' . get_quiz_link($quizid);
             $send = TRUE;
         }
         if ($row1->point == $row1->amount && $row2->share_onehundred == 1) {
             $tweet = 'I just got 100% in the quiz \'' . get_title($quizid, FALSE) . '\' on @OneExtraLap! You can do it too! ' . get_quiz_link($quizid);
             $send = TRUE;
         } elseif ($row1->point <= $row1->amount && $row2->share_took == 1) {
             $tweet = 'I just got ' . get_percentage($row1->point, $row1->amount) . ' in the quiz \'' . get_title($quizid, FALSE) . '\' on @OneExtraLap! Can you beat me? ' . get_quiz_link($quizid);
             $send = TRUE;
         }
     } else {
         if ($row2->share_badge == 1) {
             $badge_info = get_badge($badge);
             $tweet = 'I just unlocked the badge \'' . $badge_name . '\' on @OneExtraLap! http://oneextralap.com/badges/' . $badge;
             $send = TRUE;
         }
     }
     if ($send == TRUE) {
         $this->twitter->call('statuses/update', array('status' => trim($tweet)));
         return TRUE;
     }
     return FALSE;
 }
Example #2
0
										</div>
										<div><?php 
    echo sprintf($lang['stmy0025'], $_SESSION['tsconnections']);
    ?>
</div>
									</div>
								</div>
							</div>
						</div>
						<div class="progress">
							<div class="progress-bar progress-bar-warning progress-bar-striped active role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 15em; width:<?php 
    echo get_percentage($connects_for_bronze, $_SESSION['tsconnections']);
    ?>
%;">
								<?php 
    echo get_percentage($connects_for_bronze, $_SESSION['tsconnections']), $lang['stmy0022'];
    ?>
							</div>
						</div>
						<?php 
}
?>
					</div>
				</div>
			</div>
			<!-- /.container-fluid -->

		</div>
		<!-- /#page-wrapper -->

	</div>
Example #3
0
     foreach ($topLevelSuites as $key => $suiteNameID) {
         $results = $mapOfAggregate[$suiteNameID['id']];
         $element['tsuite_name'] = $suiteNameID['name'];
         $element['total_tc'] = $results['total'];
         $totals['total_tc'] += $results['total'];
         $element['percentage_completed'] = get_percentage($results['total'], $results['total'] - $results['not_run']);
         unset($results['total']);
         foreach ($results as $key => $value) {
             $element['details'][$key]['qty'] = $results[$key];
             $totals['details'][$key]['qty'] += $results[$key];
         }
         $element['details']['not_run']['qty'] = $results['not_run'];
         $arrDataSuite[$arrDataSuiteIndex] = $element;
         $arrDataSuiteIndex++;
     }
     $totals['percentage_completed'] = get_percentage($totals['total_tc'], $totals['total_tc'] - $totals['details']['not_run']['qty']);
     $arrDataSuite[$arrDataSuiteIndex] = $totals;
     $gui->statistics->testsuites = $arrDataSuite;
     // Get labels
     $dummy = current($gui->statistics->testsuites);
     foreach ($dummy['details'] as $status_verbose => $value) {
         $dummy['details'][$status_verbose]['qty'] = lang_get($tlCfg->results['status_label'][$status_verbose]);
     }
     $gui->columnsDefinition->testsuites = $dummy['details'];
 }
 // ----------------------------------------------------------------------------
 /* BUILDS REPORT */
 // $buildSet = $tplan_mgr->get_builds($args->tplan_id); //,testplan::ACTIVE_BUILDS);
 //
 //
 // $filters=null;
Example #4
0
            if ($content_type == 'home' || $content_type == 'user') {
                ?>
							<div class="left avatar">
								<?php 
                echo get_avatar($row->user_id);
                ?>
							</div>
							<div class="right update">
								<h2>
									<?php 
                echo get_fullname($row->user_id);
                ?>
 
<?php 
                if ($row->type == 'take') {
                    $percent = get_percentage($row->point, $row->amount, FALSE);
                    ?>
									got <b><?php 
                    echo $percent;
                    ?>
%</b> in 
<?php 
                } else {
                    ?>
									created 
<?php 
                }
                ?>
									the quiz <?php 
                echo get_title($row->quiz_id);
                ?>
function savedquest_options()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    echo '<div class="wrap" style="background:#fff;">';
    if (isset($_GET['tab'])) {
        $tab = $_GET['tab'];
    } else {
        $tab = "";
    }
    saved_admin_tab($tab);
    if ($tab == "quiztaken" or $tab == "") {
        ?>

		<table  class="wp-list-table widefat fixed striped pages" width="100%" style="border-spacing: 0; text-align:center;" >
			<tr>
				<th>Lesson ID</th>
				<th>Lesson Title</th>
				<th>Number Of Questions</th>
				<th>Question Answered</th>
				<th>Unanswered Question</th>
				<th>User</th>
				<th>User Id</th>
				<th>DATE And Time</th>
			</tr>
			<?php 
        $svequiz = get_option('savequiz_list');
        ?>

			<?php 
        foreach ($svequiz as $quizdata) {
            ?>

			<tr>
				<td><?php 
            echo $quizdata['lesson_id'];
            ?>
</td> 	
				<td><?php 
            echo $quizdata['lesson_title'];
            ?>
</td> 
				<td><?php 
            echo $quizdata['total_questtion'];
            ?>
</td> 
				<td><?php 
            echo $quizdata['question_answered'];
            ?>
(<?php 
            echo get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td> 
				<td><?php 
            echo $quizdata['remaining_question'];
            ?>
(<?php 
            echo 100 - get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td> 
				<td><?php 
            echo $quizdata['fullname'];
            ?>
</td>		
				<td><?php 
            echo $quizdata['user_id'];
            ?>
 </td>				
				<td><?php 
            echo $quizdata['DATETIME'];
            ?>
</td> 				
			</tr>
			<?php 
        }
        ?>

		</table>
		
	<?php 
    } elseif ($tab == "timesession") {
        $user_last_login_logout = get_option('user_last_login_logout');
        ?>

	<br /><br/>
		<table  class="wp-list-table widefat fixed striped pages" width="100%" style="border-spacing: 0; text-align:center;" >
			<tr>
				<th>User ID</th>
				<th>Full Name</th>
				<th>Last Login</th>
				<th>Last Logout</th>
				<th>Amout of Time Spent</th>
				<th>Role</th>

			</tr>
			<?php 
        $svequiz = get_option('savequiz_list');
        ?>

			<?php 
        foreach ($user_last_login_logout as $last_login_logout) {
            ?>

			<?php 
            if ($last_login_logout['user_id'] != "") {
                ?>

			<?php 
                $user_info = get_userdata($last_login_logout['user_id']);
                ?>

			<tr>
				<td><?php 
                echo $last_login_logout['user_id'];
                ?>
</td> 
				<td><?php 
                echo $user_info->display_name;
                ?>
</td> 					
				<td><?php 
                echo gettime_st($last_login_logout['logintime']);
                ?>
</td> 
				<td><?php 
                echo gettime_st($last_login_logout['logouttime']);
                ?>
</td> 
				<?php 
                if ($last_login_logout['logouttime'] != "") {
                    $date1 = date_create($last_login_logout['logintime']);
                    $date2 = date_create($last_login_logout['logouttime']);
                    $diff = date_diff($date1, $date2);
                    $diftime = $diff->format("%h Hours %i Minute %s Seconds");
                } else {
                    $diftime = "";
                }
                ?>

				
				<th><?php 
                echo $diftime;
                ?>
</th>
				<td><?php 
                echo implode(', ', $user_info->roles);
                ?>
</td>
		
			</tr>
			<?php 
            }
            ?>

			<?php 
        }
        ?>

		</table><br /><br />


	<?php 
    } elseif ($tab == "timequizecompleted") {
        global $woothemes_sensei, $post, $current_user, $wp_query, $learner_user;
        echo "<table class='wp-list-table widefat fixed striped pages'>";
        $allUsers = get_users();
        echo "<tr>\r\r\n\t\t\t\t<th>User</th>\r\r\n\t\t\t\t<th>Courses</th>\r\r\n\t\t\t\t<th>Percentage Incomplete</th>\r\r\n\t\t\t\t<th>Percentage Complete</th>\r\r\n\t\t\t\t<th>Percentage Competent</th>\r\r\n\t\t\t\t<th>Percentage Attempted</th>\r\r\n\t\t\t\t<th>Length of time Course Completed</th>\r\r\n\t\t\t  </tr>";
        foreach ($allUsers as $user) {
            $args = array('post_type' => 'course');
            $courses = get_posts($args);
            $i = 1;
            foreach ($courses as $course) {
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($course->ID, $user->ID);
                $course_status = WooThemes_Sensei_Utils::user_course_status($course->ID, $user->ID);
                $course_status_update = get_comment_meta($course_status->comment_ID);
                if (!empty($course_status)) {
                    $displayed_lessons = array();
                    $modules = Sensei()->modules->get_course_modules(intval($course->ID));
                    foreach ($modules as $module) {
                        $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($course->ID), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                        $lessons = get_posts($args);
                        if (count($lessons) > 0) {
                            $html .= '<h3>' . $module->name . '</h3>' . "\n";
                            $count = 0;
                            foreach ($lessons as $lesson_item) {
                                $lesson_grade = ' n/a';
                                $has_questions = get_post_meta($lesson_item->ID, '_quiz_has_questions', true);
                                if ($has_questions) {
                                    $lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $user->ID);
                                    // Get user quiz grade
                                    $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
                                    if ($lesson_grade) {
                                        $lesson_grade .= '%';
                                    }
                                    $modulequizdata = get_comment_meta($lesson_status->comment_ID);
                                    //echo "<a href='".get_post_permalink($lesson_item->ID)."'>".$lesson_item->post_title."</a><br />";
                                    $modulequestion_asked = count(explode(",", $modulequizdata['questions_asked'][0]));
                                    $moduleanswered_quiz = count(unserialize($modulequizdata['quiz_answers'][0]));
                                    //echo "number of questions:".$modulequestion_asked."<br />";
                                    //echo "number of Answered:".$moduleanswered_quiz."<br />";
                                    if ($course_status->comment_approved == "complete") {
                                        $attempted = "(100%)";
                                    } else {
                                        if ($modulequizdata['grade'][0] == "") {
                                            if ($lesson_status->comment_approved == "passed") {
                                                $attempted = 'P/Q';
                                            } else {
                                                if ($modulequestion_asked >= $moduleanswered_quiz) {
                                                    if ($modulequizdata['quiz_answers'][0] == "") {
                                                        $attempted = "";
                                                    } else {
                                                        $attempted = "( " . get_percentage($modulequestion_asked, $moduleanswered_quiz) . "% ) Saved";
                                                    }
                                                }
                                            }
                                        } else {
                                            $attempted = "( " . get_percentage($modulequestion_asked, $moduleanswered_quiz) . "% )";
                                        }
                                        //echo "<pre>";
                                        //echo "Attempted:".$attempted."<br />";
                                        //echo $user->user_email."<br />";
                                        //echo $modulequizdata['grade'][0]."<br />";
                                        //echo $modulequizdata['quiz_answers'][0]."<br />";
                                        //print_r($lesson_status);
                                        //echo "</pre>";
                                    }
                                }
                                $html .= '<a href="' . esc_url(get_permalink($lesson_item->ID)) . '" title="' . esc_attr(sprintf(__('Start %s', 'woothemes-sensei'), $lesson_item->post_title)) . '">' . esc_html(sprintf(__('%s', 'woothemes-sensei'), $lesson_item->post_title)) . '</a> ' . $attempted . '<br />';
                                $displayed_lessons[] = $lesson_item->ID;
                            }
                        }
                    }
                    $args = array('post_type' => 'lesson', 'posts_per_page' => -1, 'suppress_filters' => 0, 'meta_key' => '_order_' . $course->ID, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($course->ID))), 'post__not_in' => $displayed_lessons);
                    $lessons = get_posts($args);
                    //echo "Number of lesson in a course: ".count($lessons);
                    if (0 < count($lessons)) {
                        $html .= '<h3>' . __('Other Lessons', 'woothemes-sensei') . '</h3>' . "\n";
                    }
                    if ($course_status_update['percent'][0] == 100) {
                        $date1 = date_create($course_status_update['start'][0]);
                        $date2 = date_create($course_status->comment_date);
                        $diff = date_diff($date1, $date2);
                        $diftime = $diff->format("%h Hours %i Minute %s Seconds");
                    } else {
                        $diftime = "course not completed yet.";
                    }
                    $allcourseid[] = $course->ID;
                    $incomplete = 100 - $course_status_update['percent'][0];
                    echo "<tr><td>";
                    echo $user->user_email;
                    echo "</td>";
                    echo "<td>";
                    echo "<a href='" . get_post_permalink($course->ID) . "'>" . $course->post_title . "</a>";
                    echo "</td>";
                    echo "<td>";
                    echo $incomplete . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $course_status_update['percent'][0] . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $course_user_grade . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $html;
                    $html = "";
                    foreach ($lessons as $lesson_item) {
                        $lesson_grade = 'n/a';
                        $has_questions = get_post_meta($lesson_item->ID, '_quiz_has_questions', true);
                        if ($has_questions) {
                            $lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $user->ID);
                            // Get user quiz grade
                            $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
                            if ($lesson_grade) {
                                $lesson_grade .= '%';
                            }
                        }
                        $quizdata = get_comment_meta($lesson_status->comment_ID);
                        //echo "<h1>Comment</h1>";
                        //print_r(get_comment_meta( $lesson_status->comment_ID ));
                        //echo "<h1>LESSON STATUS</h1>";
                        //print_r($lesson_status);
                        echo "<a href='" . get_post_permalink($lesson_item->ID) . "'>" . $lesson_item->post_title . "</a> ";
                        //print_r($quizdata);
                        $question_asked = count(explode(",", $quizdata['questions_asked'][0]));
                        $answered_quiz = count(unserialize($quizdata['quiz_answers'][0]));
                        if ($quizdata['grade'][0] == "") {
                            if ($question_asked > $answered_quiz) {
                                echo "( " . get_percentage($question_asked, $answered_quiz) . "% )";
                            }
                        } else {
                            echo "(100%)";
                        }
                        echo '<br />';
                    }
                    // End For Loop
                    echo "</td>";
                    echo "<td>";
                    echo $diftime;
                    echo "</td>";
                    echo "</tr>";
                    //echo $course->post_title." (".$course_status_update['percent'][0]."% Complete) (". $incomplete . "% incomplete) (". $course_user_grade . "% Competent)<br />";
                    $i++;
                }
            }
        }
        echo "</table>";
    } elseif ($tab == "threshold") {
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submittreshold']) && ($_POST['submittreshold'] = "submit")) {
            // declare users and variables
            $allUsers = get_users();
            $modules_completed = $_POST['completionpermonth'];
            $courseid = $_POST['course'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name '));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($allUsers as $user) {
                //declare course function calls
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->ID);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->ID);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->ID);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->ID);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                //get the user groups
                $useringroup = new Groups_User($user->ID);
                $user_groups = $useringroup->__get('groups');
                $displayed_lessons = array();
                //declare and get module values
                $modules = Sensei()->modules->get_course_modules(intval($courseid));
                $modules_content = Sensei()->modules->course_module_content(intval($courseid));
                //echo "<pre>";
                //echo $user->user_email."<br />";
                //echo "sensei_user_course_status_message: ";
                //print_r($course_status);
                //echo "<br />";
                //echo "started_course: "."<br />";
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                //echo "</pre>";
                //module loop per user
                foreach ($modules as $module) {
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($courseid), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                    $lessons = get_posts($args);
                    $num_of_lesson = count($lessons);
                    //lessson loop per user
                    foreach ($lessons as $lesson_item) {
                        $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $user->ID);
                        if ($is_lesson_completed == 1) {
                            $lesson_completed[] = $is_lesson_completed;
                        }
                    }
                    //echo "lesson completed:". count($lesson_completed)."<br />";
                    if (count($lesson_completed) > 0) {
                        if ($num_of_lesson == count($lesson_completed)) {
                            $completed_modules_per_user[] = 1;
                            $total_module_passed[] = 1;
                            //echo "---Module completed <br />";
                        } else {
                            //echo "---Module not completed <br />";
                        }
                    } else {
                        //echo "---Module not completed <br />";
                    }
                    unset($lesson_completed);
                    unset($completed_modules_per_user);
                }
                $overaalltotal_module_passed = count($total_module_passed);
                //echo $overaalltotal_module_passed . " module being passed";
                //loop throughout the user group under a user
                if (is_array($user_groups)) {
                    foreach ($user_groups as $user_group) {
                        if ($user_group->group_id == $_POST['group']) {
                            if (!empty($user_course_status)) {
                                $modules_completed_from_groups = $user_group->description;
                                if ($modules_completed == "") {
                                    $modules_completed = $modules_completed_from_groups;
                                }
                                $num_of_module_x_difftime = $modules_completed * $diftime;
                                //echo "<br />num_of_module_x_difftime:".$num_of_module_x_difftime;
                                if ($overaalltotal_module_passed >= $num_of_module_x_difftime) {
                                    $array_to_csv[] = array($user->display_name, $course_name);
                                    //$userid_within_group[$user->user_email] = $user->ID;
                                }
                            }
                        }
                        //echo $user_group->group_id."<br />";
                    }
                }
                unset($total_module_passed);
            }
            //echo "<pre>";
            //echo $modules_completed;
            //print_r($array_to_csv);
            //echo "</pre>";
            convert_to_csv($array_to_csv, 'report-' . md5(date('Y-m-d h:i:s')) . '.csv', ',');
        }
        ?>
		<div class="form-wrap" style="padding:20px;">
			<form action="" method="post">
				
				<div>
					<label>
						Group:
					</label>
						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_groups_group`');
        ?>
					
					<select name="group">
						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->group_id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>				
				</div>
				<div>
					<label>
						Course:
					</label>
					
					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>

					
					<select name="course">
						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>
																
					</select>
					<?php 
        wp_reset_postdata();
        ?>

				</div>
				<div>				
					<label>
						How many modules should be completed by now?
					</label>	
					<input type="text" name="completionpermonth" />
				</div><br /><br />			
				<input type="submit" class="button button-primary" name="submittreshold" value="submit" />										
			</form>
		</div>	
		
		
<?php 
    } elseif ($tab == "incremental-progress") {
        wp_enqueue_script('jquery-ui-datepicker');
        wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submitincrenmental']) && ($_POST['submitincrenmental'] = "submit")) {
            // declare users and variables
            $allUsers = get_users();
            $modules_completed = $_POST['completionpermonth'];
            $courseid = $_POST['course'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name ', 'Lesson Title'));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($allUsers as $user) {
                //declare course function calls
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->ID);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->ID);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->ID);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->ID);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                //get the user groups
                $useringroup = new Groups_User($user->ID);
                $user_groups = $useringroup->__get('groups');
                $displayed_lessons = array();
                //declare and get module values
                $modules = Sensei()->modules->get_course_modules(intval($courseid));
                $modules_content = Sensei()->modules->course_module_content(intval($courseid));
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                //echo "</pre>";
                //module loop per user
                foreach ($modules as $module) {
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($courseid), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                    $lessons = get_posts($args);
                    $num_of_lesson = count($lessons);
                    //lessson loop per user
                    foreach ($lessons as $lesson_item) {
                        $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $user->ID);
                        $lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $user->ID);
                        $modulequizdata = get_comment_meta($lesson_status->comment_ID);
                        if (!empty($lesson_status->comment_date)) {
                            echo "<pre>";
                            //echo $lesson_status->comment_date."<br />";
                            //echo $_POST['date1']."<br />";
                            $lesson_completion_date = date("Y-m-d", strtotime($lesson_status->comment_date));
                            //echo "<br />";
                            //echo $_POST['date2']."<br />";
                            //echo "lesson is completed:".$is_lesson_completed."<br />";
                            //print_r($lesson_item);
                            echo "</pre>";
                        }
                        if ($is_lesson_completed == 1) {
                            $date1 = strtotime($_POST['date1']);
                            $date2 = strtotime($_POST['date2']);
                            $lesson_completion_date_str = strtotime($lesson_completion_date);
                            if ($lesson_completion_date_str > $date1 && $lesson_completion_date_str < $date2) {
                                //echo "lesson is completed:".$is_lesson_completed."<br />";
                                //echo "user ".$user->display_name." pass this". $lesson_completion_date;
                                $user_id_onrange[$user->ID] = $lesson_item->post_title;
                            }
                        }
                    }
                    //echo "lesson completed:". count($lesson_completed)."<br />";
                }
                //loop throughout the user group under a user
                if (is_array($user_groups)) {
                    foreach ($user_groups as $user_group) {
                        if ($user_group->group_id == $_POST['group']) {
                            if (!empty($user_course_status)) {
                                if (array_key_exists($user->ID, $user_id_onrange)) {
                                    $array_to_csv[] = array($user->display_name, $course_name, $user_id_onrange[$user->ID]);
                                }
                            }
                        }
                        //echo $user_group->group_id."<br />";
                    }
                }
            }
            //print_r($user_id_onrange);
            //echo "<pre>";
            //echo $modules_completed;
            //print_r($array_to_csv);
            //echo "</pre>";
            convert_to_csv($array_to_csv, 'report-incremental-progress' . md5(date('Y-m-d h:i:s')) . '.csv', $headers);
        }
        ?>
		<div class="form-wrap" style="padding:20px;">
			<form action="" method="post">
				
				<div>
					<label>
						Group:
					</label>
						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_groups_group`');
        ?>
					
					<select name="group">
						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->group_id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>				
				</div><br />
				<div>
					<label>
						Course:
					</label>
					
					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>

					
					<select name="course">
						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>
																
					</select>
					<?php 
        wp_reset_postdata();
        ?>

				</div><br />
				<div>				
					<label>
						Date:
					</label>	
					From<input type="text" id="date1" name="date1" /> to <input type="text" id="date2" name="date2" />
				</div><br /><br />			
				<input type="submit" class="button button-primary" name="submitincrenmental" value="submit" />										
			</form>
		</div>	
		<script>
			jQuery(document).ready(function() {
				jQuery('#date1').datepicker({
					dateFormat : 'yy-mm-dd'
				});
				jQuery('#date2').datepicker({
					dateFormat : 'yy-mm-dd'
				});				
				
				
			});
		</script>
		
<?php 
    } elseif ($tab == "total-progress") {
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submittotalprogress']) && ($_POST['submittotalprogress'] = "submit")) {
            // declare users and variables
            $allUsers = get_users();
            $modules_completed = $_POST['completionpermonth'];
            $courseid = $_POST['course'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name', 'Lesson Title'));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($allUsers as $user) {
                //declare course function calls
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->ID);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->ID);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->ID);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->ID);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                //get the user groups
                $useringroup = new Groups_User($user->ID);
                $user_groups = $useringroup->__get('groups');
                $displayed_lessons = array();
                //declare and get module values
                $modules = Sensei()->modules->get_course_modules(intval($courseid));
                $modules_content = Sensei()->modules->course_module_content(intval($courseid));
                //echo "<pre>";
                //echo $user->user_email."<br />";
                //echo "sensei_user_course_status_message: ";
                //print_r($course_status);
                //echo "<br />";
                //echo "started_course: "."<br />";
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                //echo "</pre>";
                //module loop per user
                foreach ($modules as $module) {
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($courseid), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                    $lessons = get_posts($args);
                    $num_of_lesson = count($lessons);
                    //lessson loop per user
                    foreach ($lessons as $lesson_item) {
                        $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_item->ID, $user->ID);
                        if ($is_lesson_completed == 1) {
                            $lesson_taken[$user->ID][] = $lesson_item->post_title;
                        }
                    }
                }
                $overaalltotal_module_passed = count($total_module_passed);
                //echo $overaalltotal_module_passed . " module being passed";
                //loop throughout the user group under a user
                if (is_array($user_groups)) {
                    foreach ($user_groups as $user_group) {
                        if ($user_group->group_id == $_POST['group']) {
                            if (!empty($user_course_status)) {
                                $array_to_csv[] = array($user->display_name, $course_name, join("|", $lesson_taken[$user->ID]));
                                //$userid_within_group[$user->user_email] = $user->ID;
                            }
                        }
                        //echo $user_group->group_id."<br />";
                    }
                }
                //echo "<pre>";
                //print_r($lesson_taken);
                //echo "<pre>";
                unset($total_module_passed);
                unset($lesson_taken);
            }
            //echo "<pre>";
            //echo $modules_completed;
            //print_r($array_to_csv);
            //echo "</pre>";
            convert_to_csv($array_to_csv, 'report-total-progress' . md5(date('Y-m-d h:i:s')) . '.csv', ',');
        }
        ?>
		<div class="form-wrap" style="padding:20px;">
			<form action="" method="post">
				
				<div>
					<label>
						Group:
					</label>
						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_groups_group`');
        ?>
					
					<select name="group">
						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->group_id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>				
				</div>
				<div>
					<label>
						Course:
					</label>
					
					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>

					
					<select name="course">
						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>
																
					</select>
					<?php 
        wp_reset_postdata();
        ?>

				</div>
				<br /><br />			
				<input type="submit" class="button button-primary" name="submittotalprogress" value="submit" />										
			</form>
		</div>	
		
		
<?php 
    }
    echo '</div>';
}
Example #6
0
echo $db_arr[9]['name'];
echo $db_arr[9]['online'] == '1' ? ' (Status: <font color="#00FF00">Online</font>)' : ' (Status: <font color="#FF0000">Offline</font>)';
?>
</h4>
                        <div class="progress">
                            <div class="progress-bar progress-bar-success progress-bar-striped <?php 
echo $db_arr[9]['online'] == '1' ? 'active' : '';
?>
" role="progressbar" aria-valuenow="<?php 
echo get_percentage($db_arr[0]['count'], $db_arr[9]['count']);
?>
" aria-valuemin="0" aria-valuemax="100" style="min-width: 20em;width: <?php 
echo get_percentage($db_arr[0]['count'], $db_arr[9]['count']);
?>
%"><?php 
echo '<font color="#000000">' . round($db_arr[9]['count'] / 3600) . ' Hours (' . get_percentage($db_arr[0]['count'], $db_arr[9]['count']) . ' % - Compared To #1)</font>';
?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-3">
                        <h2>Top 10 Statistics</h2>
                        <div class="panel panel-primary">
                            <div class="panel-heading">
                                <h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> Top 10 Vs Others In Online Time</h3>
                            </div>
                            <div class="panel-body">
                                <div id="top10vs_donut1"></div>
                            </div>
Example #7
0
echo $client_data[9]['name'];
echo $client_data[9]['online'] == '1' ? ' (Status: <span class="text-success">' . $lang['stix0024'] . '</span>)' : ' (Status: <span class="text-danger">' . $lang['stix0025'] . '</span>)';
?>
</h4>
						<div class="progress">
							<div class="progress-bar progress-bar-striped <?php 
echo $client_data[9]['online'] == '1' ? 'active' : '';
?>
" role="progressbar" aria-valuenow="<?php 
echo get_percentage($client_data[0]['count'], $client_data[9]['count']);
?>
" aria-valuemin="0" aria-valuemax="100" style="min-width: 20em;width: <?php 
echo get_percentage($client_data[0]['count'], $client_data[9]['count']);
?>
%"><?php 
echo sprintf($lang['sttw0006'], round($client_data[9]['count'] / 3600), get_percentage($client_data[0]['count'], $client_data[9]['count']));
?>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-lg-12">
						<h2><?php 
echo $lang['sttw0007'];
?>
</h2>
						<div class="col-lg-3">
							<div class="panel panel-primary">
								<div class="panel-heading">
									<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i>&nbsp;<?php 
        $number_ofquestions = count($_POST['questions_asked']);
        $question_answered = count($_POST['sensei_question']);
        $remaining_question = $number_ofquestions - $question_answered;
        $blogtime = current_time('mysql');
        $array_savequiz['total_questtion'] = $number_ofquestions;
        $array_savequiz['question_answered'] = $question_answered;
        $array_savequiz['remaining_question'] = $remaining_question;
        $array_savequiz['DATETIME'] = $blogtime;
        $array_savequiz['lesson_id'] = $post->ID;
        $array_savequiz['lesson_title'] = get_the_title();
        $array_savequiz['user_id'] = $current_user->ID;
        $array_savequiz['fullname'] = $current_user->display_name;
        $svequiz = get_option('savequiz_list');
        if (empty($svequiz)) {
            $svequiz[] = $array_savequiz;
        } else {
            $svequiz[] = $array_savequiz;
        }
        /*
		echo "<pre>";
		print_r($svequiz);
		echo "</pre>";
		*/
        update_option('savequiz_list', $svequiz);
        // process $_POST data here
    }
    if (isset($_POST['course_start'])) {
        $user_course_data = get_user_meta($current_user->ID, 'user_course_data', true);
        if (!empty($user_course_data)) {
            $user_course_data[$post->ID]['course_title'] = $post->post_title;
            $user_course_data[$post->ID]['start_date'] = current_time('mysql');
            update_user_meta($current_user->ID, 'user_course_data', $usermeta_course_value);
        } else {
            $usermeta_course_value[$post->ID]['course_title'] = $post->post_title;
            $usermeta_course_value[$post->ID]['start_date'] = current_time('mysql');
            update_user_meta($current_user->ID, 'user_course_data', $usermeta_course_value);
        }
    }
}
add_action('admin_menu', 'savedquest_function');
function savedquest_function()
{
    add_options_page('Saved Quest Options', 'Saved Quiz', 'manage_options', 'saved-quiz-data', 'savedquest_options');
}
function get_percentage($total, $number)
{
    if ($total > 0) {
        return round($number / ($total / 100), 2);
    } else {
        return 0;
    }
}
function gettime_st($date)
{
    if ($date != "") {
        $date = new DateTime($date);
        return $result = $date->format('F d Y, l H:i:s');
    }
}
function savedquest_options()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    echo '<div class="wrap" style="background:#fff;">';
    if (isset($_GET['tab'])) {
        $tab = $_GET['tab'];
    } else {
        $tab = "";
    }
    saved_admin_tab($tab);
    if ($tab == "quiztaken" or $tab == "") {
        ?>

		<table border="1" width="100%" style="border-spacing: 0; text-align:center;" >
			<tr>
				<th>Lesson ID</th>
				<th>Lesson Title</th>
				<th>Number Of Questions</th>
				<th>Question Answered</th>
				<th>Unanswered Question</th>
				<th>User</th>
				<th>User Id</th>
				<th>DATE And Time</th>
			</tr>
			<?php 
        $svequiz = get_option('savequiz_list');
        ?>

			<?php 
        foreach ($svequiz as $quizdata) {
            ?>

			<tr>
				<td><?php 
            echo $quizdata['lesson_id'];
            ?>
</td> 	
				<td><?php 
            echo $quizdata['lesson_title'];
            ?>
</td> 
				<td><?php 
            echo $quizdata['total_questtion'];
            ?>
</td> 
				<td><?php 
            echo $quizdata['question_answered'];
            ?>
(<?php 
            echo get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td> 
				<td><?php 
            echo $quizdata['remaining_question'];
            ?>
(<?php 
            echo 100 - get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td> 
				<td><?php 
            echo $quizdata['fullname'];
            ?>
</td>		
Example #9
0
<?php

if (DEBUG) {
    $total_time = $time_end - $time_start;
    echo "Did it in  " . $total_time . " seconds\n";
    echo '<ul>';
    if (isset($GLOBALS['debug']['timer']['start'])) {
        foreach ($GLOBALS['debug']['timer']['start'] as $event_name => $val) {
            $taken = $GLOBALS['debug']['timer']['end'][$event_name] - $GLOBALS['debug']['timer']['start'][$event_name];
            echo '<li>' . $event_name . ' took ' . $taken . ' seconds, ' . get_percentage($total_time, $taken) . '% of overall time. </li>';
        }
    }
    echo '</ul>';
}
Example #10
0
 $mapOfAggregate = $re->getAggregateMap();
 $arrDataSuite = null;
 $arrDataSuiteIndex = 0;
 // collect data for top test suites and users
 if (is_array($topLevelSuites)) {
     foreach ($topLevelSuites as $key => $suiteNameID) {
         $results = $mapOfAggregate[$suiteNameID['id']];
         $element['tsuite_name'] = $suiteNameID['name'];
         $element['total_tc'] = $results['total'];
         $element['percentage_completed'] = get_percentage($results['total'], $results['total'] - $results['not_run']);
         // BUGID 4377 - do not unset total now, because we need in foreach loop
         // unset($results['total']);
         foreach ($results as $key => $value) {
             $element['details'][$key]['qty'] = $results[$key];
             // add percentage for each result
             $element['details'][$key]['percentage'] = get_percentage($results['total'], $results[$key]);
         }
         unset($element['details']['total']);
         $element['details']['not_run']['qty'] = $results['not_run'];
         $arrDataSuite[$arrDataSuiteIndex] = $element;
         $arrDataSuiteIndex++;
     }
     $gui->statistics->testsuites = $arrDataSuite;
     // Get labels
     $dummy = current($gui->statistics->testsuites);
     foreach ($dummy['details'] as $status_verbose => $value) {
         $dummy['details'][$status_verbose]['percentage'] = lang_get('in_percent');
         $dummy['details'][$status_verbose]['qty'] = lang_get($tlCfg->results['status_label'][$status_verbose]);
     }
     $gui->columnsDefinition->testsuites = $dummy['details'];
 }
function savedquest_options()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    echo '<div class="wrap" style="background:#fff;">';
    if (isset($_GET['tab'])) {
        $tab = $_GET['tab'];
    } else {
        $tab = "";
    }
    saved_admin_tab($tab);
    if ($tab == "quiztaken" or $tab == "") {
        ?>

		<table  class="wp-list-table widefat fixed striped pages" width="100%" style="border-spacing: 0; text-align:center;" >

			<tr>

				<th>Lesson ID</th>

				<th>Lesson Title</th>

				<th>Module</th>

				<th>Number Of Questions</th>

				<th>Question Answered</th>

				<th>Unanswered Question</th>

				<th>User</th>

				<th>User Id</th>

				<th>DATE And Time</th>

			</tr>

			<?php 
        $svequiz = get_option('savequiz_list');
        ?>

			<?php 
        foreach ($svequiz as $quizdata) {
            ?>

			<tr>

				<td><?php 
            echo $quizdata['lesson_id'];
            ?>
</td>

				<td><?php 
            echo $quizdata['lesson_title'];
            ?>
</td>

				<td>

				<?php 
            $terms = get_the_terms($quizdata['lesson_id'], 'module');
            echo $terms[0]->name;
            //print_r($terms);
            ?>

				</td>

				<td><?php 
            echo $quizdata['total_questtion'];
            ?>
</td>

				<td><?php 
            echo $quizdata['question_answered'];
            ?>
(<?php 
            echo get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td>

				<td><?php 
            echo $quizdata['remaining_question'];
            ?>
(<?php 
            echo 100 - get_percentage($quizdata['total_questtion'], $quizdata['question_answered']) . "%";
            ?>
)</td>

				<td><?php 
            echo $quizdata['fullname'];
            ?>
</td>

				<td><?php 
            echo $quizdata['user_id'];
            ?>
 </td>

				<td><?php 
            echo $quizdata['DATETIME'];
            ?>
</td>

			</tr>

			<?php 
        }
        ?>

		</table>



	<?php 
    } elseif ($tab == "timesession") {
        $user_last_login_logout = get_option('user_last_login_logout');
        ?>

	<br /><br/>

		<table  class="wp-list-table widefat fixed striped pages" width="100%" style="border-spacing: 0; text-align:center;" >

			<tr>

				<th>User ID</th>

				<th>Full Name</th>

				<th>Last Login</th>

				<th>Last Logout</th>

				<th>Amout of Time Spent</th>

				<th>Role</th>



			</tr>

			<?php 
        $svequiz = get_option('savequiz_list');
        ?>

			<?php 
        foreach ($user_last_login_logout as $last_login_logout) {
            ?>

			<?php 
            if ($last_login_logout['user_id'] != "") {
                ?>

			<?php 
                $user_info = get_userdata($last_login_logout['user_id']);
                ?>

			<tr>

				<td><?php 
                echo $last_login_logout['user_id'];
                ?>
</td>

				<td><?php 
                echo $user_info->display_name;
                ?>
</td>

				<td><?php 
                echo gettime_st($last_login_logout['logintime']);
                ?>
</td>

				<td><?php 
                echo gettime_st($last_login_logout['logouttime']);
                ?>
</td>

				<?php 
                if ($last_login_logout['logouttime'] != "") {
                    $date1 = date_create($last_login_logout['logintime']);
                    $date2 = date_create($last_login_logout['logouttime']);
                    $diff = date_diff($date1, $date2);
                    $diftime = $diff->format("%h Hours %i Minute %s Seconds");
                } else {
                    $diftime = "";
                }
                ?>



				<th><?php 
                echo $diftime;
                ?>
</th>

				<td><?php 
                echo implode(', ', $user_info->roles);
                ?>
</td>



			</tr>

			<?php 
            }
            ?>

			<?php 
        }
        ?>

		</table><br /><br />





	<?php 
    } elseif ($tab == "timequizecompleted") {
        global $woothemes_sensei, $post, $current_user, $wp_query, $learner_user;
        echo "<table class='wp-list-table widefat fixed striped pages'>";
        $allUsers = get_users();
        echo "<tr>\n\n\t\t\t\t<th>User</th>\n\n\t\t\t\t<th>Courses</th>\n\n\t\t\t\t<th>Percentage Incomplete</th>\n\n\t\t\t\t<th>Percentage Complete</th>\n\n\t\t\t\t<th>Percentage Competent</th>\n\n\t\t\t\t<th>Percentage Attempted</th>\n\n\t\t\t\t<th>Length of time Course Completed</th>\n\n\t\t\t  </tr>";
        foreach ($allUsers as $user) {
            $args = array('post_type' => 'course');
            $courses = get_posts($args);
            $i = 1;
            foreach ($courses as $course) {
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($course->ID, $user->ID);
                $course_status = WooThemes_Sensei_Utils::user_course_status($course->ID, $user->ID);
                $course_status_update = get_comment_meta($course_status->comment_ID);
                if (!empty($course_status)) {
                    $displayed_lessons = array();
                    $modules = Sensei()->modules->get_course_modules(intval($course->ID));
                    foreach ($modules as $module) {
                        $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($course->ID), 'compare' => '=')), 'tax_query' => array(array('taxonomy' => Sensei()->modules->taxonomy, 'field' => 'id', 'terms' => intval($module->term_id))), 'meta_key' => '_order_module_' . $module->term_id, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'suppress_filters' => 0);
                        $lessons = get_posts($args);
                        if (count($lessons) > 0) {
                            $html .= '<h3>' . $module->name . '</h3>' . "\n";
                            $count = 0;
                            foreach ($lessons as $lesson_item) {
                                $lesson_grade = ' n/a';
                                $has_questions = get_post_meta($lesson_item->ID, '_quiz_has_questions', true);
                                if ($has_questions) {
                                    $lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $user->ID);
                                    // Get user quiz grade
                                    $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
                                    if ($lesson_grade) {
                                        $lesson_grade .= '%';
                                    }
                                    $modulequizdata = get_comment_meta($lesson_status->comment_ID);
                                    //echo "<a href='".get_post_permalink($lesson_item->ID)."'>".$lesson_item->post_title."</a><br />";
                                    $modulequestion_asked = count(explode(",", $modulequizdata['questions_asked'][0]));
                                    $moduleanswered_quiz = count(unserialize($modulequizdata['quiz_answers'][0]));
                                    //echo "number of questions:".$modulequestion_asked."<br />";
                                    //echo "number of Answered:".$moduleanswered_quiz."<br />";
                                    //echo "<pre>";
                                    //echo "<h1>".$user->user_email.$lesson_item->post_title."</h1>";
                                    //print_r($course_status );
                                    //echo $course_status->comment_approved;
                                    //echo $modulequestion_asked."------".$moduleanswered_quiz;
                                    //echo "</pre>";
                                    if ($course_status->comment_approved == "complete") {
                                        $attempted = '<span style="color:green;">(100%)</span>';
                                    } else {
                                        if ($lesson_status->comment_approved == "passed" || $lesson_status->comment_approved == "graded") {
                                            $attempted = '<span style="color:green;">(100%)</span>';
                                        } else {
                                            $attempted = "";
                                        }
                                    }
                                    //echo "<pre>";
                                    //echo "Attempted:".$attempted."<br />";
                                    //echo $user->user_email."<br />";
                                    //echo $modulequizdata['grade'][0]."<br />";
                                    //echo $modulequizdata['quiz_answers'][0]."<br />";
                                    //print_r($lesson_status);
                                    //echo "</pre>";
                                }
                                $html .= '<a href="' . esc_url(get_permalink($lesson_item->ID)) . '" title="' . esc_attr(sprintf(__('Start %s', 'woothemes-sensei'), $lesson_item->post_title)) . '">' . esc_html(sprintf(__('%s', 'woothemes-sensei'), $lesson_item->post_title)) . '</a> ' . $attempted . '<br />';
                                $displayed_lessons[] = $lesson_item->ID;
                            }
                        }
                    }
                    $args = array('post_type' => 'lesson', 'posts_per_page' => -1, 'suppress_filters' => 0, 'meta_key' => '_order_' . $course->ID, 'orderby' => 'meta_value_num date', 'order' => 'ASC', 'meta_query' => array(array('key' => '_lesson_course', 'value' => intval($course->ID))), 'post__not_in' => $displayed_lessons);
                    $lessons = get_posts($args);
                    //echo "Number of lesson in a course: ".count($lessons);
                    if (0 < count($lessons)) {
                        $html .= '<h3>' . __('Other Lessons', 'woothemes-sensei') . '</h3>' . "\n";
                    }
                    if ($course_status_update['percent'][0] == 100) {
                        $date1 = date_create($course_status_update['start'][0]);
                        $date2 = date_create($course_status->comment_date);
                        $diff = date_diff($date1, $date2);
                        $diftime = $diff->format("%h Hours %i Minute %s Seconds");
                    } else {
                        $diftime = "course not completed yet.";
                    }
                    $allcourseid[] = $course->ID;
                    $incomplete = 100 - $course_status_update['percent'][0];
                    echo "<tr><td>";
                    echo $user->user_email;
                    echo "</td>";
                    echo "<td>";
                    echo "<a href='" . get_post_permalink($course->ID) . "'>" . $course->post_title . "</a>";
                    echo "</td>";
                    echo "<td>";
                    echo $incomplete . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $course_status_update['percent'][0] . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $course_user_grade . "%";
                    echo "</td>";
                    echo "<td>";
                    echo $html;
                    $html = "";
                    foreach ($lessons as $lesson_item) {
                        $lesson_grade = 'n/a';
                        $has_questions = get_post_meta($lesson_item->ID, '_quiz_has_questions', true);
                        if ($has_questions) {
                            $lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_item->ID, $user->ID);
                            // Get user quiz grade
                            $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
                            if ($lesson_grade) {
                                $lesson_grade .= '%';
                            }
                        }
                        $quizdata = get_comment_meta($lesson_status->comment_ID);
                        //echo "<h1>Comment</h1>";
                        //print_r(get_comment_meta( $lesson_status->comment_ID ));
                        //echo "<h1>LESSON STATUS</h1>";
                        //print_r($lesson_status);
                        echo "<a href='" . get_post_permalink($lesson_item->ID) . "'>" . $lesson_item->post_title . "</a> ";
                        //print_r($quizdata);
                        $question_asked = count(explode(",", $quizdata['questions_asked'][0]));
                        $answered_quiz = count(unserialize($quizdata['quiz_answers'][0]));
                        $lessonquestion_asked = count(explode(",", $quizdata['questions_asked'][0]));
                        $lessonanswered_quiz = count(unserialize($quizdata['quiz_answers'][0]));
                        if ($course_status->comment_approved == "complete") {
                            echo $attempted = '<span style="color:green;">(100%)</span>';
                        } else {
                            if ($lesson_status->comment_approved == "passed" || $lesson_status->comment_approved == "graded") {
                                echo $attempted = '<span style="color:green;">(100%)</span>';
                            } else {
                                echo $attempted = "";
                            }
                        }
                        /*if($quizdata ['grade'][0]==""){
                        
                        
                        
                        									if($lesson_status->comment_approved=="passed"){
                        
                        
                        
                        										 echo  $attempted = 'P/Q';
                        
                        
                        
                        									}else{
                        
                        
                        
                        										if($lessonquestion_asked>=$lessonanswered_quiz){
                        
                        
                        
                        											 if($modulequizdata['quiz_answers'][0]==""){
                        
                        
                        
                        												$attempted = "";
                        
                        
                        
                        											 }else{
                        
                        
                        
                        												 echo $attempted =  "( ". get_percentage($lessonquestion_asked, $lessonanswered_quiz)."% ) <span style='color:red;'>Saved</span>";
                        
                        
                        
                        											 }
                        
                        
                        
                        										}
                        
                        
                        
                        									}
                        
                        
                        
                        
                        
                        
                        
                        								}else{
                        
                        
                        
                        									if($lesson_status->comment_approved=="passed"){
                        
                        
                        
                        										 echo  $attempted = '100%  <span style="color:red;">complete button</span>';
                        
                        
                        
                        									}else{
                        
                        
                        
                        										$percentage = get_percentage($lessonquestion_asked, $lessonanswered_quiz);
                        
                        
                        
                        										if((int)$lessonquestion_asked>1){
                        
                        
                        
                        										}
                        
                        
                        
                        									}
                        
                        
                        
                        								}*/
                        echo '<br />';
                    }
                    // End For Loop
                    echo "</td>";
                    echo "<td>";
                    echo $diftime;
                    echo "</td>";
                    echo "</tr>";
                    //echo $course->post_title." (".$course_status_update['percent'][0]."% Complete) (". $incomplete . "% incomplete) (". $course_user_grade . "% Competent)<br />";
                    $i++;
                }
            }
        }
        echo "</table>";
    } elseif ($tab == "threshold") {
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submittreshold']) && ($_POST['submittreshold'] = "submit")) {
            // declare users and variables
            $completionpermonth = $_POST['completionpermonth'];
            $courseid = $_POST['course'];
            $group_id = $_POST['group'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name', 'Module(s)'));
            $userincourse = BuddyPress_Sensei_Groups::bp_sensei_get_course_members($courseid);
            //groups_get_groupmeta
            //echo $group_attached = groups_get_groupmeta( $group_id, 'bp_course_attached', true)."<br />---";
            if ($completionpermonth == "") {
                $completionpermonth = groups_get_groupmeta($group_id, 'sensei_threshold', true);
            }
            /* echo "<pre>";
            
            			print_r($userincourse);
            
            			echo "</pre>";
            
            			echo "<pre>";
            
            			print_r($user_in_groups);
            
            			echo "</pre>";	 */
            $user_in_groups = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM wp_bp_groups_members WHERE group_id = %d", $group_id));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($user_in_groups as $user) {
                //echo "user_id ".$user->user_id."<br />";
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->user_id);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->user_id);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->user_id);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->user_id);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                $modules = Sensei()->modules->get_course_modules($courseid);
                //$modules_content = Sensei()->modules->course_module_content(  $courseid );
                foreach ($modules as $module) {
                    $module_id = $module->term_id;
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'module', 'field' => 'id', 'terms' => $module_id)), 'meta_query' => array(array('key' => '_lesson_course', 'value' => $courseid)), 'fields' => 'ids');
                    $lessons = get_posts($args);
                    $completed = false;
                    $lesson_count = 0;
                    $completed_count = 0;
                    foreach ($lessons as $lesson_id) {
                        $completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_id, $user->user_id);
                        ++$lesson_count;
                        if ($completed) {
                            ++$completed_count;
                        }
                    }
                    $module_progress = $completed_count / $lesson_count * 100;
                    if ($module_progress == 100) {
                        $module_passed[] = 1;
                        $module_name[] = $module->name;
                    }
                    /* 	echo "<pre>";
                    
                    						echo $module_progress;
                    
                    						echo "---<br />";
                    
                    						//print_r($modules_content);
                    
                    						echo "</pre>"; */
                }
                $course_status_info['start'][0];
                $datenow = date('Y-m-d h:i:s');
                $date1 = date_create($course_status_info['start'][0]);
                $date2 = date_create($datenow);
                $diff = date_diff($date1, $date2);
                $diftime = $diff->format("%m");
                if ($diftime < 1) {
                    $diftime = 1;
                }
                $num_of_module_x_difftime = $completionpermonth * $diftime;
                //echo "<br />num_of_module_x_difftime:".$num_of_module_x_difftime;
                //echo count($module_passed)." module passed<br />";
                if (count($module_passed) >= $num_of_module_x_difftime) {
                    $user_info = get_userdata($user->user_id);
                    $array_to_csv[] = array($user_info->display_name, $course_name, join("|", $module_name));
                    //$userid_within_group[$user->user_email] = $user->ID;
                }
                unset($module_name);
                unset($module_passed);
            }
            /* echo "<pre>";
            
            			print_r($array_to_csv);
            
            			echo "</pre>"; */
            convert_to_csv($array_to_csv, 'report-' . md5(date('Y-m-d h:i:s')) . '.csv', ',');
        }
        ?>
		<div class="form-wrap" style="padding:20px;">

			<form action="" method="post">



				<div>

					<label>

						Group:

					</label>

						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_bp_groups`');
        ?>

					<select name="group">

						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>

				</div>

				<div>

					<label>

						Course:

					</label>



					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>



					<select name="course">

						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>

					</select>

					<?php 
        wp_reset_postdata();
        ?>

				</div>

				<div>

					<label>

						How many modules should be completed by now?

					</label>

					<input type="text" name="completionpermonth" />

				</div><br /><br />

				<input type="submit" class="button button-primary" name="submittreshold" value="submit" />

			</form>

		</div>





<?php 
    } elseif ($tab == "incremental-progress") {
        wp_enqueue_script('jquery-ui-datepicker');
        wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submitincrenmental']) && ($_POST['submitincrenmental'] = "submit")) {
            // declare users and variables
            $courseid = $_POST['course'];
            $group_id = $_POST['group'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name', 'Percentage Completed', 'Percentage Competent', 'Email'));
            $userincourse = BuddyPress_Sensei_Groups::bp_sensei_get_course_members($courseid);
            $user_in_groups = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM wp_bp_groups_members WHERE group_id = %d", $group_id));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($user_in_groups as $user) {
                //echo "user_id ".$user->user_id."<br />";
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->user_id);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->user_id);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->user_id);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->user_id);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                $modules = Sensei()->modules->get_course_modules($courseid);
                //$modules_content = Sensei()->modules->course_module_content(  $courseid );
                foreach ($modules as $module) {
                    $module_id = $module->term_id;
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'module', 'field' => 'id', 'terms' => $module_id)), 'meta_query' => array(array('key' => '_lesson_course', 'value' => $courseid)), 'fields' => 'ids');
                    $lessons = get_posts($args);
                    $completed = false;
                    $lesson_count = 0;
                    $completed_count = 0;
                    foreach ($lessons as $lesson_id) {
                        $completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_id, $user->user_id);
                        ++$lesson_count;
                        if ($completed) {
                            ++$completed_count;
                        }
                    }
                    $module_progress = $completed_count / $lesson_count * 100;
                    if ($module_progress == 100) {
                        $module_passed[] = 1;
                    }
                    /* 	echo "<pre>";
                    
                    						echo $module_progress;
                    
                    						echo "---<br />";
                    
                    						//print_r($modules_content);
                    
                    						echo "</pre>"; */
                }
                if ($course_status_info['percent'][0] != 0) {
                    /* echo $user_course_status->comment_date."dsaddas"."<br />"; */
                    $date1 = strtotime($_POST['date1']);
                    $date2 = strtotime($_POST['date2']);
                    $lesson_completion_date_str = strtotime($user_course_status->comment_date);
                    if ($lesson_completion_date_str > $date1 && $lesson_completion_date_str < $date2) {
                        //echo "lesson is completed:".$is_lesson_completed."<br />";
                        //echo "user ".$user->display_name." pass this". $lesson_completion_date;
                        $user_info = get_userdata($user->user_id);
                        $array_to_csv[] = array($user_info->display_name, $course_name, $course_status_info['percent'][0] . '%', $course_user_grade . '%', $user_info->user_email);
                        //$user_id_onrange[$user->ID] = $lesson_item->post_title;
                    }
                }
                unset($module_passed);
            }
            /* echo "<pre>";
            
            						print_r($array_to_csv);
            
            						echo "</pre>";  */
            $daterange1 = $_POST['date1'];
            $daterange2 = $_POST['date2'];
            convert_to_csv($array_to_csv, 'report-inc-progress_' . $daterange1 . '_' . $daterange2 . '_group_' . $groupname . '_courseID_' . $courseid . '.csv', $headers);
        }
        ?>
		<div class="form-wrap" style="padding:20px;">

			<form action="" method="post" id="incrementalval">



				<div>

					<label>

						Group:

					</label>

						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_bp_groups`');
        ?>

					<select name="group">

						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>

				</div><br />

				<div>

					<label>

						Course:

					</label>



					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>



					<select name="course">

						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>

					</select>

					<?php 
        wp_reset_postdata();
        ?>

				</div><br />

				<div>

					<label>

						Date:

					</label>

					From<input type="text" id="date1" name="date1" required /> to <input type="text" id="date2" name="date2" required />

				</div><br /><br />

				<input type="submit" class="button button-primary" name="submitincrenmental" value="submit"  />

			</form>

		</div>

		<script>

			jQuery(document).ready(function() {

				jQuery('#date1').datepicker({

					dateFormat : 'yy-mm-dd'

				});

				jQuery('#date2').datepicker({

					dateFormat : 'yy-mm-dd'

				});









			});

		</script>



<?php 
    } elseif ($tab == "total-progress") {
        //declare the wpdb for custom query
        global $wpdb;
        //check for submitted data
        if (isset($_POST['submittotalprogress']) && ($_POST['submittotalprogress'] = "submit")) {
            // declare users and variables
            $courseid = $_POST['course'];
            $group_id = $_POST['group'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name', 'Percentage Completed', 'Percentage Competent', 'Email'));
            $userincourse = BuddyPress_Sensei_Groups::bp_sensei_get_course_members($courseid);
            $user_in_groups = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM wp_bp_groups_members WHERE group_id = %d", $group_id));
            //user loop ----- loop user get the groups and course the course they take
            foreach ($user_in_groups as $user) {
                //echo "user_id ".$user->user_id."<br />";
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->user_id);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->user_id);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->user_id);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->user_id);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                $modules = Sensei()->modules->get_course_modules($courseid);
                //$modules_content = Sensei()->modules->course_module_content(  $courseid );
                foreach ($modules as $module) {
                    $module_id = $module->term_id;
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'module', 'field' => 'id', 'terms' => $module_id)), 'meta_query' => array(array('key' => '_lesson_course', 'value' => $courseid)), 'fields' => 'ids');
                    $lessons = get_posts($args);
                    $completed = false;
                    $lesson_count = 0;
                    $completed_count = 0;
                    foreach ($lessons as $lesson_id) {
                        $completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_id, $user->user_id);
                        ++$lesson_count;
                        if ($completed) {
                            ++$completed_count;
                        }
                    }
                    $module_progress = $completed_count / $lesson_count * 100;
                    if ($module_progress == 100) {
                        $module_passed[] = 1;
                    }
                }
                $user_info = get_userdata($user->user_id);
                if ($user->user_id != 1) {
                    $percentcomplete = $course_status_info['percent'][0];
                    if ($percentcomplete == "") {
                        $percentcomplete = '0';
                    }
                    $array_to_csv[] = array($user_info->display_name, $course_name, $percentcomplete . '%', $course_user_grade . '%', $user_info->user_email);
                }
            }
            convert_to_csv($array_to_csv, 'report-total-progress_' . date('Y-m-d') . '_group_' . $groupname . '_courseID_' . $courseid . '.csv', ',');
        }
        ?>
		<div class="form-wrap" style="padding:20px;">

			<form action="" method="post">



				<div>

					<label>

						Group:

					</label>

						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_bp_groups`');
        ?>

					<select name="group">

						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>

				</div>

				<div>

					<label>

						Course:

					</label>



					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>



					<select name="course">

						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>

					</select>

					<?php 
        wp_reset_postdata();
        ?>

				</div>

				<br /><br />

				<input type="submit" class="button button-primary" name="submittotalprogress" value="submit" />

			</form>

		</div>





<?php 
    } elseif ($tab == "master-report") {
        //declare the wpdb for custom query
        global $wpdb;
        global $woothemes_sensei, $post, $current_user, $wp_query, $learner_user;
        //check for submitted data
        if (isset($_POST['master-report']) && ($_POST['master-report'] = "submit")) {
            // declare users and variables
            $courseid = $_POST['course'];
            $group_id = $_POST['group'];
            $course_name = get_the_title($courseid);
            $array_to_csv = array(array('Student Name', 'Course Name', 'Percentage Completed', 'Percentage Competent', 'Email'));
            $userincourse = BuddyPress_Sensei_Groups::bp_sensei_get_course_members($courseid);
            $user_in_groups = $wpdb->get_results($wpdb->prepare("SELECT user_id FROM wp_bp_groups_members WHERE group_id = %d", $group_id));
            //user loop ----- loop user get the groups and course the course they take
            $maincontent = "";
            $countloop_user = 0;
            $lesson_title = "<th align='center'>User</th>";
            foreach ($user_in_groups as $user) {
                $maincontent .= "<tr>";
                $user_info = get_userdata($user->user_id);
                $maincontent .= "<td>" . $user_info->display_name . "</td>";
                $course_user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($courseid, $user->user_id);
                $user_course_status = WooThemes_Sensei_Utils::user_course_status($courseid, $user->user_id);
                $course_status_info = get_comment_meta($user_course_status->comment_ID);
                $started_course = WooThemes_Sensei_Utils::user_started_course($courseid, $user->user_id);
                $course_status = WooThemes_Sensei_Utils::sensei_user_course_status_message($courseid, $user->user_id);
                $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
                $modules = Sensei()->modules->get_course_modules($courseid);
                //$modules_content = Sensei()->modules->course_module_content(  $courseid );
                foreach ($modules as $module) {
                    $module_id = $module->term_id;
                    $args = array('post_type' => 'lesson', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'module', 'field' => 'id', 'terms' => $module_id)), 'meta_query' => array(array('key' => '_lesson_course', 'value' => $courseid)), 'fields' => 'ids', 'order' => 'ASC');
                    $lessons = get_posts($args);
                    $completed = false;
                    $lesson_count = 0;
                    $completed_count = 0;
                    foreach ($lessons as $lesson_id) {
                        if ($countloop_user != 1) {
                            $lesson_title .= "<th style=\"font-size:10px;\">";
                            $lesson_title .= get_the_title($lesson_id);
                            $lesson_title .= "</th>";
                        }
                        // Get quiz pass setting
                        $pass_required = get_post_meta($lesson_id, '_pass_required', true);
                        // Get quiz pass mark
                        $quiz_passmark = abs(round(doubleval(get_post_meta($lesson_id, '_quiz_passmark', true)), 2));
                        // Get latest quiz answers and grades
                        //$lesson_id = $woothemes_sensei->quiz->get_lesson_id( $lesson_id );
                        $user_quizzes = $woothemes_sensei->quiz->get_user_answers($lesson_id, $user->user_id);
                        $user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user->user_id);
                        $user_quiz_grade = 0;
                        if (isset($user_lesson_status->comment_ID)) {
                            $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
                        }
                        // Check again that the lesson is complete
                        $user_lesson_end = WooThemes_Sensei_Utils::user_completed_lesson($user_lesson_status);
                        $completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson_id, $user->user_id);
                        /* 							echo "<pre>";
                        
                        							echo get_the_title($lesson_id);
                        
                        							echo 'pass_required:'."<br />";
                        
                        							print_r($pass_required);
                        
                        
                        
                        							echo 'quiz_passmark:<br />';
                        
                        							print_r($quiz_passmark);
                        
                        
                        
                        							echo 'user_quizzes:<br />';
                        
                        							print_r($user_quizzes);
                        
                        
                        
                        							echo 'user_lesson_status:<br />';
                        
                        							print_r($user_lesson_status);
                        
                        
                        
                        							echo 'Percent Competent:<br />';
                        
                        							print_r($user_quiz_grade);
                        
                        
                        
                        							echo 'completed--:'.$completed."<br />";
                        
                        							echo 'user_lesson_end--:'.$user_lesson_end."<br />";
                        
                        
                        
                        
                        
                        							echo "_quiz_has_questions:".get_post_meta( $lesson_id, '_quiz_has_questions', true )."<br /><br />";
                        
                        							echo "this is the lersson info-----------------:";
                        
                        							 print_r(get_comment_meta( $user_lesson_status->comment_ID ));
                        
                        							$lessonquizdata = get_comment_meta( $user_lesson_status->comment_ID );
                        
                        							echo "lessonquizdata---:";
                        
                        								print_r(unserialize($lessonquizdata['quiz_answers'][0]));
                        
                        							echo "</pre>";	 */
                        $maincontent .= "<td>";
                        if ($completed == 1) {
                            $percentcompleted = '100%';
                        } else {
                            $lessonquizdata = get_comment_meta($user_lesson_status->comment_ID);
                            $lessonquizdata_asked = count(explode(",", $lessonquizdata['questions_asked'][0]));
                            $lessonquizdataanswered_quiz = count(unserialize($lessonquizdata['quiz_answers'][0]));
                            $lquizcounter = 0;
                            foreach ($lessonquizdataanswered_quiz as $lquiz) {
                                if ($lquiz != "") {
                                    $lquizcounter++;
                                }
                            }
                            /* echo "<pre>";
                            
                            								echo $lessonquizdata_asked."<br />";
                            
                            								print_r($lessonquizdata);
                            
                            								print_r(unserialize($lessonquizdata['quiz_answers'][0]));
                            
                            								echo "</pre>"; */
                            if ($user_lesson_status->comment_approved == "passed" || $user_lesson_status->comment_approved == "graded") {
                                $percentcompleted = '100%';
                            } else {
                                $percentcompleted = get_percentage($lessonquizdata_asked, $lquizcounter) . '%';
                            }
                        }
                        $maincontent .= '%S: ' . $percentcompleted . "<br />";
                        $maincontent .= '%C: ' . $user_quiz_grade . "%";
                        $maincontent .= "</td>";
                        ++$lesson_count;
                        if ($completed) {
                            ++$completed_count;
                        }
                    }
                    $module_progress = $completed_count / $lesson_count * 100;
                    if ($module_progress == 100) {
                        $module_passed[] = 1;
                    }
                }
                $countloop_user = 1;
                $user_info = get_userdata($user->user_id);
                $completionpermonth = groups_get_groupmeta($group_id, 'sensei_threshold', true);
                if (count($module_passed) >= $completionpermonth) {
                    $ontract = "yes";
                } else {
                    $ontract = "no";
                }
                $maincontent .= "<td>" . $ontract . "</td>";
                if ($completed_course == 1) {
                    $completed_course = $user_course_status->comment_date;
                } else {
                    $completed_course = "No";
                }
                $maincontent .= "<td>" . $completed_course . "</td>";
                $maincontent .= "</tr>";
                unset($module_passed);
            }
            echo '<table  class="wp-list-table widefat fixed striped pages" style="width:500%; border-spacing: 0; text-align:center;" >';
            echo "<tr>";
            echo $lesson_title;
            echo "<td>On Track Or Not</td>";
            echo "<td>Course Completed</td>";
            echo "</tr>";
            echo $maincontent;
            echo "</table>";
            /* echo "<pre>";
            
            						print_r($array_to_csv);
            
            						echo "</pre>"; */
            //convert_to_csv($array_to_csv, 'report-total-progress_'.date('Y-m-d').'_group_'.$groupname.'_courseID_'.$courseid.'.csv', ',');
        }
        ?>
		<div class="form-wrap" style="padding:20px;">

			<form action="" method="post">



				<div>

					<label>

						Group:

					</label>

						<?php 
        $groups = $wpdb->get_results('SELECT * FROM `wp_bp_groups`');
        ?>

					<select name="group" required>

						<option value="">- Select One -</option>

						<?php 
        foreach ($groups as $group) {
            echo "<option value='" . $group->id . "'>";
            echo $group->name;
            echo "</option>";
        }
        ?>

					</select>

				</div>

				<div>

					<label>

						Course:

					</label>



					<?php 
        $course = new WP_Query(array('post_type' => 'course'));
        ?>



					<select name="course" required>

						<option value="">- Select One -</option>

						<?php 
        // The Loop
        if ($course->have_posts()) {
            while ($course->have_posts()) {
                $course->the_post();
                echo '<option value="' . $course->post->ID . '">' . get_the_title() . '</option>';
            }
        }
        /* Restore original Post Data */
        ?>

					</select>

					<?php 
        wp_reset_postdata();
        ?>

				</div>

				<br /><br />

				<input type="submit" class="button button-primary" name="master-report" value="submit" />

			</form>

		</div>





<?php 
    }
    //end master-report
    echo '</div>';
}
Example #12
0
                                <?php 
include '../../includes/getgrades.php';
?>
                            </table>
                            <div class="well well-sm text-right">
                            	Current grade total: 
                            	<?php 
echo $totalPoints . " / " . $maxPointsTotal . " ";
function get_percentage($total, $number)
{
    if ($total > 0) {
        return round($number / ($total / 100), 2);
    } else {
        return 0;
    }
}
echo "(" . get_percentage($maxPointsTotal, $totalPoints) . "%)";
?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    
    </div>

    

</body>
</html>
Example #13
0
 function get_average_grade($quizid)
 {
     $row =& get_instance()->db->query("SELECT AVG(point) AS point, amount FROM score WHERE quiz_id='{$quizid}' AND type='take'")->row();
     return get_percentage($row->point, $row->amount);
 }
				      <div class="box-footer no-padding">
				        <ul class="nav nav-stacked">
				          <li><a href="javascript:void(0)">在线天数<span class="pull-right badge bg-aqua"><?php 
echo $reg_days;
?>
</span></a></li>
				          <li><a href="javascript:void(0)">灵修天数<span class="pull-right badge btn-warning"><?php 
echo $spiri_total_count;
?>
</span></a></li>
				          <li><a href="javascript:void(0)">亏欠天数<span class="pull-right badge bg-aqua"><?php 
echo $reg_days - $spiri_total_count;
?>
</span></a></li>				          
				          <li><a href="javascript:void(0)">总灵修率<span class="pull-right badge bg-red"><?php 
echo get_percentage($spiri_total_count, $reg_days);
?>
</span></a></li>
				          <li><a href="javascript:void(0)">小组排名<span class="pull-right badge bg-aqua"><?php 
echo $group_ranking_result;
?>
</span></a></li>
				          <li><a href="javascript:void(0)">团契排名<span class="pull-right badge bg-aqua"><?php 
echo $tq_ranking_result;
?>
</span></a></li>				          
				          <li><a href="javascript:void(0)">本周灵修总次数<span class="pull-right badge bg-aqua"><?php 
echo $spiri_week_count;
?>
</span></a></li>
				          <li><a href="javascript:void(0)">本周祷告总次数<span class="pull-right badge bg-blue"><?php 
Example #15
0
             $dummy['details'][$status_verbose]['qty'] = lang_get($tlCfg->results['status_label'][$status_verbose]);
             $dummy['details'][$status_verbose]['percentage'] = "[%]";
         }
         $gui->columnsDefinition->{$item} = $dummy['details'];
     }
 }
 $mapOfAggregate = $re->getAggregateMap();
 $arrDataSuite = null;
 $arrDataSuiteIndex = 0;
 // collect data for top test suites and users
 if (is_array($topLevelSuites)) {
     foreach ($topLevelSuites as $key => $suiteNameID) {
         $results = $mapOfAggregate[$suiteNameID['id']];
         $element['tsuite_name'] = $suiteNameID['name'];
         $element['total_tc'] = $results['total'];
         $element['percentage_completed'] = get_percentage($results['total'], $results['total'] - $results['not_run']);
         unset($results['total']);
         foreach ($results as $key => $value) {
             $element['details'][$key]['qty'] = $results[$key];
         }
         $element['details']['not_run']['qty'] = $results['not_run'];
         $arrDataSuite[$arrDataSuiteIndex] = $element;
         $arrDataSuiteIndex++;
     }
     $gui->statistics->testsuites = $arrDataSuite;
     // Get labels
     $dummy = current($gui->statistics->testsuites);
     foreach ($dummy['details'] as $status_verbose => $value) {
         $dummy['details'][$status_verbose]['qty'] = lang_get($tlCfg->results['status_label'][$status_verbose]);
     }
     $gui->columnsDefinition->testsuites = $dummy['details'];
Example #16
0
    echo get_percentage($connects_for_silver, $_SESSION['tsconnections']);
} else {
    echo get_percentage($connects_for_bronze, $_SESSION['tsconnections']);
}
?>
%;"><font color="#000000"><?php 
if ($_SESSION['tsconnections'] >= $connects_for_legendary) {
    echo 'Progress Completed';
} elseif ($_SESSION['tsconnections'] < $connects_for_legendary && $_SESSION['tsconnections'] >= $connects_for_gold) {
    echo get_percentage($connects_for_legendary, $_SESSION['tsconnections']) . '% Completed For Legendary';
} elseif ($_SESSION['tsconnections'] < $connects_for_gold && $_SESSION['tsconnections'] >= $connects_for_silver) {
    echo get_percentage($connects_for_gold, $_SESSION['tsconnections']) . '% Completed For Gold';
} elseif ($_SESSION['tsconnections'] < $connects_for_silver && $_SESSION['tsconnections'] >= $connects_for_bronze) {
    echo get_percentage($connects_for_silver, $_SESSION['tsconnections']) . '% Completed For Silver';
} else {
    echo get_percentage($connects_for_bronze, $_SESSION['tsconnections']) . '% Completed For Bronze';
}
?>
</font></div>
                        </div>
                        <h3>Battle Achievement Progress</h3>
                        <div class="progress">
                            <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"><span class="sr-only"></span></div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->