} else { echo '-'; } } else { _e('Non-assessable', 'cp'); } ?> </td> <td class="column-comment <?php echo $style . ' ' . $visibility_class; ?> "> <?php if (count($response) >= 1) { $comment = Unit_Module::get_response_comment($response->ID); } if (isset($comment)) { ?> <a class="response_comment" alt="<?php echo esc_attr(strip_tags($comment)); ?> " title="<?php echo esc_attr(strip_tags($comment)); ?> ">✓</a> <?php } else { echo '-'; } ?>
$overall_grade = $overall_grade + $grade; } else { _e('Pending grade', 'cp'); } } else { echo '0%'; } $assessable_answers++; } else { _e('Non-assessable', 'cp'); } ?> </td> </tr> <?php $comment = Unit_Module::get_response_comment($id); if (!empty($comment)) { ?> <tr> <td colspan="4" style="background-color:#FF6600; color:#fff; margin-left:30px;"> <?php echo $comment; ?> </td> </tr> <?php } ?> </table> <?php
function student_workbook_table($args) { ob_start(); extract(shortcode_atts(array('module_column_title' => __('Element', 'cp'), 'title_column_title' => __('Title', 'cp'), 'submission_date_column_title' => __('Submitted', 'cp'), 'response_column_title' => __('Answer', 'cp'), 'grade_column_title' => __('Grade', 'cp'), 'comment_column_title' => __('Comment', 'cp'), 'module_response_description_label' => __('Description', 'cp'), 'comment_label' => __('Comment', 'cp'), 'view_link_label' => __('View', 'cp'), 'view_link_class' => 'assessment-view-response-link button button-units', 'comment_link_class' => 'assessment-view-response-link button button-units', 'pending_grade_label' => __('Pending', 'cp'), 'unit_unread_label' => __('Unit Unread', 'cp'), 'unit_read_label' => __('Unit Read', 'cp'), 'single_correct_label' => __('Correct', 'cp'), 'single_incorrect_label' => __('Incorrect', 'cp'), 'non_assessable_label' => __('**'), 'table_class' => 'widefat shadow-table assessment-archive-table', 'table_labels_th_class' => 'manage-column'), $args)); $module_column_title = sanitize_text_field($module_column_title); $title_column_title = sanitize_text_field($title_column_title); $submission_date_column_title = sanitize_text_field($submission_date_column_title); $response_column_title = sanitize_text_field($response_column_title); $grade_column_title = sanitize_text_field($grade_column_title); $comment_column_title = sanitize_text_field($comment_column_title); $module_response_description_label = sanitize_text_field($module_response_description_label); $comment_label = sanitize_text_field($comment_label); $view_link_label = sanitize_text_field($view_link_label); $view_link_class = sanitize_html_class($view_link_class); $comment_link_class = sanitize_html_class($comment_link_class); $pending_grade_label = sanitize_text_field($pending_grade_label); $unit_unread_label = sanitize_text_field($unit_unread_label); $unit_read_label = sanitize_text_field($unit_read_label); $non_assessable_label = sanitize_text_field($non_assessable_label); $table_class = sanitize_html_class($table_class); $table_labels_th_class = sanitize_html_class($table_labels_th_class); $single_correct_label = sanitize_text_field($single_correct_label); $single_incorrect_label = sanitize_text_field($single_incorrect_label); $columns = array("title" => $title_column_title, "submission_date" => $submission_date_column_title, "response" => $response_column_title, "grade" => $grade_column_title, "comment" => $comment_column_title); $col_sizes = array('45', '15', '10', '13', '5'); ?> <table cellspacing="0" class="<?php echo $table_class; ?> "> <thead> <tr> <?php $n = 0; foreach ($columns as $key => $col) { ?> <th class="<?php echo $table_labels_th_class; ?> column-<?php echo $key; ?> " width="<?php echo $col_sizes[$n] . '%'; ?> " id="<?php echo $key; ?> " scope="col"><?php echo $col; ?> </th> <?php $n++; } ?> </tr> </thead> <?php $user_object = new Student(get_current_user_ID()); $modules = Unit_Module::get_modules(get_the_ID()); $input_modules_count = 0; foreach ($modules as $mod) { $class_name = $mod->module_type; if (class_exists($class_name)) { if (constant($class_name . '::FRONT_SAVE')) { $input_modules_count++; } } } $current_row = 0; $style = ''; foreach ($modules as $mod) { $class_name = $mod->module_type; if (class_exists($class_name)) { if (constant($class_name . '::FRONT_SAVE')) { $response = call_user_func($class_name . '::get_response', $user_object->ID, $mod->ID); $visibility_class = count($response) >= 1 ? '' : 'less_visible_row'; if (count($response) >= 1) { $grade_data = Unit_Module::get_response_grade($response->ID); } if (isset($_GET['ungraded']) && $_GET['ungraded'] == 'yes') { if (count($response) >= 1 && !$grade_data) { $general_col_visibility = true; } else { $general_col_visibility = false; } } else { $general_col_visibility = true; } $style = isset($style) && 'alternate' == $style ? '' : ' alternate'; ?> <tr id='user-<?php echo $user_object->ID; ?> ' class="<?php echo $style; echo 'row-' . $current_row; ?> "> <?php if ($general_col_visibility) { ?> <td class="<?php echo $style . ' ' . $visibility_class; ?> "> <?php echo $mod->post_title; ?> </td> <td class="<?php echo $style . ' ' . $visibility_class; ?> "> <?php echo count($response) >= 1 ? date_i18n('M d, Y', strtotime($response->post_date)) : __('Not submitted', 'cp'); ?> </td> <td class="<?php echo $style . ' ' . $visibility_class; ?> "> <?php if (count($response) >= 1) { ?> <div id="response_<?php echo $response->ID; ?> " style="display:none;"> <?php if (isset($mod->post_content) && $mod->post_content !== '') { ?> <div class="module_response_description"> <label><?php echo $module_response_description_label; ?> </label> <?php echo $mod->post_content; ?> </div> <?php } ?> <?php echo call_user_func($class_name . '::get_response_form', get_current_user_ID(), $mod->ID); ?> <?php if (is_object($response) && !empty($response)) { $comment = Unit_Module::get_response_comment($response->ID); if (!empty($comment)) { ?> <label class="comment_label"><?php echo $comment_label; ?> </label> <div class="response_comment_front"><?php echo $comment; ?> </div> <?php } } ?> </div> <a class="<?php echo sanitize_html_class($view_link_class); ?> thickbox" href="#TB_inline?width=500&height=300&inlineId=response_<?php echo $response->ID; ?> "><?php echo sanitize_html_class($view_link_label); ?> </a> <?php } else { echo '-'; } ?> </td> <td class="<?php echo $style . ' ' . $visibility_class; ?> "> <?php if (isset($grade_data)) { $grade = $grade_data['grade']; $instructor_id = $grade_data['instructor']; $instructor_name = get_userdata($instructor_id); $grade_time = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $grade_data['time']); } if (count($response) >= 1) { if (isset($grade_data)) { if (get_post_meta($mod->ID, 'gradable_answer', true) == 'no') { echo $non_assessable_label; } else { if ('radio_input_module' == $class_name) { if (100 == $grade) { echo $single_correct_label; } else { echo $single_incorrect_label; } } else { echo $grade . '%'; } } } else { if (get_post_meta($mod->ID, 'gradable_answer', true) == 'no') { echo $non_assessable_label; } else { echo $pending_grade_label; } } } else { echo '-'; } ?> </td> <td class="<?php echo $style . ' ' . $visibility_class; ?> td-center"> <?php if (!empty($response)) { $comment = Unit_Module::get_response_comment($response->ID); if (!empty($comment)) { ?> <a alt="<?php echo strip_tags($comment); ?> " title="<?php echo strip_tags($comment); ?> " class="<?php echo $comment_link_class; ?> thickbox" href="#TB_inline?width=500&height=300&inlineId=response_<?php echo $response->ID; ?> "><i class="fa fa-comment"></i></a> <?php } } else { echo '<i class="fa fa-comment-o"></i>'; } ?> </td> <?php } //general col visibility ?> </tr> <?php $current_row++; } } } if (!isset($input_modules_count) || isset($input_modules_count) && $input_modules_count == 0) { ?> <tr> <td colspan="7"> <?php $unit_grade = do_shortcode('[course_unit_details field="student_unit_grade" unit_id="' . get_the_ID() . '"]'); _e('0 input elements in the selected unit.', 'cp'); ?> <?php if ($unit_grade == 0) { echo $unit_unread_label; } else { echo $unit_read_label; } ?> </td> </tr> <?php } ?> <?php if (0 < $current_row) { ?> <tfoot><tr><td colspan="6">** <?php _e('Non-assessable elements.', 'cp'); ?> </td></tr></tfoot> <?php } ?> </table> <?php $content = ob_get_clean(); return $content; }