<span style="color: #4b4d4d; font-family: Lato; font-size: 14px;">We had you guys do a customization a while back such that assignments would display an explanation/answer to students only after they submit that assignment. I was provided with the following code, but it no longer works. I was hoping for an update/fix:</span>
add_filter('wplms_assignments_metabox','custom_explantion');
function custom_explantion($wplms_assignments_metabox){
$wplms_assignments_metabox[]=array( // Single checkbox
'label' => __('Explanation','vibe-customtypes'), // <label>
'desc' => __('Assignment explanation','vibe-customtypes'), // description
'id' => $prefix.'explanation', // field id and name
'type' => 'editor', // type of field
'std' => ''
);
return $wplms_assignments_metabox;
}
add_action('wplms_assignment_after_content','show_explanation');
function show_explanation(){
global $post;
if(is_user_logged_in()){
$user_id=get_current_user_id();
$user_time = get_user_meta($user_id,$post->ID,true);
$assignment_time = get_post_meta($post->ID,'vibe_assignment_duration',true);
$assignment_duration_parameter = apply_filters('vibe_assignment_duration_parameter',86400);
$expiry = $user_time+$assignment_time* $assignment_duration_parameter;
$assignment_finished = get_post_meta($post->ID,$user_id,true);
if(isset($assignment_finished) && is_numeric($assignment_finished) && $expiry < time()){
$explanation= get_post_meta( $post->ID,'explanation',true);
if(isset($explanation) && !empty($explanation))
echo apply_filters('the_content',$explanation);
}
}
}
Duplicate topic and will continue the discussion on the original topic:
https://wplms.io/support/forums/topic/assignment-answersexplanations/
Therefore closing the topic.