本文整理汇总了PHP中Unit::get_units_from_course方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::get_units_from_course方法的具体用法?PHP Unit::get_units_from_course怎么用?PHP Unit::get_units_from_course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::get_units_from_course方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _version_1_upgrade
public static function _version_1_upgrade($student_id, $course_id, $data)
{
// Get units
$units = Unit::get_units_from_course($course_id, 'any', true);
if (!empty($units)) {
// Traverse units
foreach ($units as $unit_id) {
// Get visited pages data
$visited_pages = get_user_option('visited_unit_pages_' . $unit_id . '_page', $student_id);
$visited_pages = explode(',', $visited_pages);
if (!empty($visited_pages)) {
foreach ($visited_pages as $page) {
if (!empty($page)) {
self::record_visited_page($student_id, $course_id, $unit_id, $page, $data);
//cp_write_log( 'Record visited page: Unit: ' . $unit_id . ' Page: ' . $page );
}
}
}
// Get modules
$modules = Unit_Module::get_modules($unit_id, 0, true);
$input_modules = Unit_Module::get_input_module_types();
if (!empty($modules)) {
// Traverse modules
foreach ($modules as $module_id) {
$module_type = Unit_Module::get_module_type($module_id);
$module_is_input = in_array($module_type, $input_modules);
// Only for input modules
if ($module_is_input) {
$module_meta = Unit_Module::get_module_meta($module_id);
// Did the student answer it?
$response = call_user_func($module_type . '::get_response', get_current_user_id(), $module_id, 'inherit', -1, true);
// Yes
if (!empty($response)) {
if ('yes' == $module_meta['mandatory_answer']) {
self::record_mandatory_answer($student_id, $course_id, $unit_id, $module_id, $data);
//cp_write_log( 'Record mandatory answer: Module: ' . $module_id );
}
if ('yes' == $module_meta['gradable_answer']) {
foreach ($response as $answer) {
$result = Unit_Module::get_response_grade($answer);
if (0 < $result['grade']) {
self::record_gradable_result($student_id, $course_id, $unit_id, $module_id, $result['grade'], $data);
}
//cp_write_log( 'Record gradable result: Module: ' . $module_id . ' Result: ' . $result['grade'] );
}
}
}
// End responses
}
// End input module
}
// End Modules loop
}
// End Modules
}
// End Units loop
}
// End Units
// Remove CoursePress transients
global $wpdb;
$table = $wpdb->prefix . 'options';
$sql = $wpdb->prepare("DELETE FROM {$table} WHERE `option_name` LIKE %s OR `option_name` LIKE %s", '%_transient_coursepress_course%', '%_transient_coursepress_unit%');
$wpdb->query($sql);
// Record the new version
self::_update_version($student_id, $course_id, $data, 1);
//cp_write_log( 'Upgraded Course: ' . $course_id . ' to version: ' . 1 );
}
示例2: isset
if (CoursePress_Capabilities::can_change_course_unit_status($course_id, $unit_id)) {
$unit->change_status($_GET['new_status']);
}
}
// cp_write_log(' preview redir: ' . $_POST['preview_redirect'] );
$preview_redirect = isset($_REQUEST['preview_redirect']) ? $_REQUEST['preview_redirect'] : 'no';
?>
<div class='wrap mp-wrap nocoursesub unit-details cp-wrap' id='cp-unit-details-holder'>
<div id="undefined-sticky-wrapper" class="sticky-wrapper">
<div class="sticky-slider visible-small visible-extra-small"><i class="fa fa-chevron-circle-right"></i></div>
<ul id="sortable-units" class="mp-tabs" style="">
<?php
// $units = $course->get_units();
// $course_id = isset( $course ) && isset( $course->details ) && ! empty( $course->details->ID ) ? $course->details->ID : 0;
$units = Unit::get_units_from_course($course_id, 'any', false);
$units = !empty($units) ? $units : array();
?>
<input type="hidden" name="unit_count" value="<?php
echo $units ? count($units) : 0;
?>
" />
<?php
$list_order = 1;
foreach ($units as $unit) {
$unit_object = new Unit($unit->ID);
$unit_object = $unit_object->get_unit();
?>
<li class="mp-tab <?php
echo isset($_GET['unit_id']) && $unit->ID == $_GET['unit_id'] ? 'active' : '';
?>
示例3: get_course_time_estimation
public static function get_course_time_estimation($course_id, $status = 'any')
{
$course_time = '';
$course_seconds = 0;
$units = Unit::get_units_from_course($course_id, $status, false);
foreach ($units as $unit) {
$unit_details = new Unit($unit->ID);
$unit_time = $unit_details->get_unit_time_estimation($unit->ID);
$min_sec = explode(':', $unit_time);
if (isset($min_sec[0])) {
$course_seconds += intval($min_sec[0]) * 60;
}
if (isset($min_sec[1])) {
$course_seconds += intval(substr($min_sec[1], 0, 2));
}
}
$total_seconds = round($course_seconds);
$formatted_time = sprintf('%02d:%02d:%02d', $total_seconds / 3600, $total_seconds / 60 % 60, $total_seconds % 60);
$course_time = apply_filters('coursepress_course_get_time_estimation', $formatted_time, $total_seconds, $course_id);
return $course_time;
}