本文整理汇总了PHP中Unit::get_unit_availability_status方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::get_unit_availability_status方法的具体用法?PHP Unit::get_unit_availability_status怎么用?PHP Unit::get_unit_availability_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::get_unit_availability_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: module_status
function module_status($atts)
{
ob_start();
extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'unit_id' => false, 'message' => __('%d of %d mandatory elements completed.', 'cp'), 'format' => 'true'), $atts, 'module_status'));
$message = sanitize_text_field($message);
$format = sanitize_text_field($format);
$format = 'true' == $format ? true : false;
if ($course_id) {
$course_id = (int) $course_id;
}
$unit_id = (int) $unit_id;
if (empty($unit_id)) {
return '';
}
$criteria = Unit::get_module_completion_data($unit_id);
$unit_status = Unit::get_unit_availability_status($unit_id);
$unit_available = Unit::is_unit_available($unit_id, $unit_status);
$input_modules_count = count($criteria['all_input_ids']);
$assessable_input_modules_count = count($criteria['gradable_modules']);
$mandatory_input_elements = count($criteria['mandatory_modules']);
$mandatory_responses = Student_Completion::get_mandatory_steps_completed(get_current_user_id(), $course_id, $unit_id);
// $all_responses = do_shortcode( '[course_unit_details field="student_module_responses"]' );
// $is_unit_available = do_shortcode( '[course_unit_details field="is_unit_available"]' );
// $input_modules_count = do_shortcode( '[course_unit_details field="input_modules_count"]' );
// $assessable_input_modules_count = do_shortcode( '[course_unit_details field="assessable_input_modules_count"]' );
// $mandatory_input_elements = do_shortcode( '[course_unit_details field="mandatory_input_modules_count"]' );
// $mandatory_responses = do_shortcode( '[course_unit_details field="student_module_responses" additional="mandatory"]' );
// $all_responses = do_shortcode( '[course_unit_details field="student_module_responses"]' );
$unit = new Unit($unit_id);
$unit->status = $unit_status;
if ($input_modules_count > 0) {
?>
<span class="unit-archive-single-module-status"><?php
if ($unit_available) {
if ($mandatory_input_elements > 0) {
echo sprintf($message, $mandatory_responses, $mandatory_input_elements);
}
} else {
if (isset($unit->status) && $unit->status['mandatory_required']['enabled'] && !$unit->status['mandatory_required']['result'] && !$unit->status['completion_required']['enabled']) {
esc_html_e('All mandatory answers are required in previous unit.', 'cp');
} elseif (isset($unit->status) && $unit->status['completion_required']['enabled'] && !$unit->status['completion_required']['result']) {
esc_html_e('Previous unit must be completed successfully.', 'cp');
}
if (isset($unit->status) && !$unit->status['date_restriction']['result']) {
echo __('Available', 'cp') . ' ' . date_i18n(get_option('date_format'), strtotime(do_shortcode('[course_unit_details field="unit_availability"]')));
}
}
?>
</span>
<?php
} else {
?>
<span class="unit-archive-single-module-status"><?php
if ($unit_available) {
// _e('Read-only','cp');
} else {
if (isset($unit->status) && $unit->status['mandatory_required']['enabled'] && !$unit->status['mandatory_required']['result'] && !$unit->status['completion_required']['enabled']) {
esc_html_e('All mandatory answers are required in previous unit.', 'cp');
} elseif (isset($unit->status) && $unit->status['completion_required']['enabled'] && !$unit->status['completion_required']['result']) {
esc_html_e('Previous unit must be completed successfully.', 'cp');
}
if (isset($unit->status) && !empty($unit->status) && !$unit->status['date_restriction']['result']) {
echo __('Available', 'cp') . ' ' . date_i18n(get_option('date_format'), strtotime(do_shortcode('[course_unit_details field="unit_availability"]')));
}
}
?>
</span>
<?php
}
$content = ob_get_clean();
return $content;
}