在作业批准后,LearnDash Auto完成了主题
因此,我已经在WordPress中创建了一个ED-Tech网站,并使用了LearnDash LMS系统,但是我想做一些事情,例如,教师批准了作业,因此它将自动完成该主题并显示完整的标记,目前在批准分配学生后批准了该主题单击“单击并继续”按钮后,需要完成该分配主题。
我还创建了一个函数并在此处附加代码。
代码从这里开始:
add_action('acf/save_post', 'assignment_custom_acf_save', 5);
function assignment_custom_acf_save($post_id) {
if (get_post_type($post_id) == 'sfwd-assignment') {
$prev_value = get_field('custom_approval_status', $post_id);
$current_values = $_POST['acf'];
$new_status = $current_values['field_628fdf0a73412'];
$assignment = get_post($post_id);
$assignment_data = get_post_meta($assignment->ID);
$student_id = $assignment->post_author;
$course_id = $assignment_data['course_id'][0];
$course_title = get_post_field('post_title', $assignment_data['course_id'][0]);
$lesson_id = $assignment_data['lesson_id'][0];
$lesson_title = $assignment_data['lesson_title'][0];
$teachers_comment = $current_values['field_628fdef373411'];
if ($new_status == 1) {
delete_post_meta($post_id, 'approval_status');
learndash_process_mark_incomplete($student_id, $course_id, $lesson_id);
send_email_after_assignment_rejection($post_id, $teachers_comment);
$rejection_message = 'Thanks for your submission for <b><a href="' . get_permalink($lesson_id) . '">' . $lesson_title . '</a></b> in the ' .
'<b><a href="' . get_permalink($course_id) . '">' . $course_title . '</a></b>.<br><br>' .
'Unfortunately, it didn\'t meet the requirements for this assignment.<br>' .
(empty($teachers_comment) ? '' : 'This is the comment to your work: <b>' . $teachers_comment . '</b>') .
'<br><br>Let\'s give it another go!';
send_new_message($student_id, $rejection_message);
} else if ($new_status == 2) {
update_post_meta($post_id, 'approval_status', 1);
learndash_process_mark_complete(I am not sure what should I put here because I am not able to create a topic id);
send_email_after_assignment_approval($post_id, $teachers_comment);
$approval_message = 'Great job on your assignment! <br><b>' . $teachers_comment . '</b>' . (empty($teachers_comment) ? '' : '<br>') .
'Your submission for <b><a href="' . get_permalink($lesson_id) . '">' . $lesson_title . '</a></b> in the ' .
'<b><a href="' . get_permalink($course_id) . '">' . $course_title . '</a></b> is now approved. <br>Thanks for spending the time to get that in.';
send_new_message($student_id, $approval_message);
}
}
}
So I have created an ed-tech website in WordPress and used the Learndash LMS system but I want to do something like if the instructor approves an assignment so it will automatically complete that topic and shows the complete mark, currently after approval of the assignments student need to complete that assignment topic after clicking on "Click and Continue" button.
I also created a function and also attaching the code here.
Code starts here:
add_action('acf/save_post', 'assignment_custom_acf_save', 5);
function assignment_custom_acf_save($post_id) {
if (get_post_type($post_id) == 'sfwd-assignment') {
$prev_value = get_field('custom_approval_status', $post_id);
$current_values = $_POST['acf'];
$new_status = $current_values['field_628fdf0a73412'];
$assignment = get_post($post_id);
$assignment_data = get_post_meta($assignment->ID);
$student_id = $assignment->post_author;
$course_id = $assignment_data['course_id'][0];
$course_title = get_post_field('post_title', $assignment_data['course_id'][0]);
$lesson_id = $assignment_data['lesson_id'][0];
$lesson_title = $assignment_data['lesson_title'][0];
$teachers_comment = $current_values['field_628fdef373411'];
if ($new_status == 1) {
delete_post_meta($post_id, 'approval_status');
learndash_process_mark_incomplete($student_id, $course_id, $lesson_id);
send_email_after_assignment_rejection($post_id, $teachers_comment);
$rejection_message = 'Thanks for your submission for <b><a href="' . get_permalink($lesson_id) . '">' . $lesson_title . '</a></b> in the ' .
'<b><a href="' . get_permalink($course_id) . '">' . $course_title . '</a></b>.<br><br>' .
'Unfortunately, it didn\'t meet the requirements for this assignment.<br>' .
(empty($teachers_comment) ? '' : 'This is the comment to your work: <b>' . $teachers_comment . '</b>') .
'<br><br>Let\'s give it another go!';
send_new_message($student_id, $rejection_message);
} else if ($new_status == 2) {
update_post_meta($post_id, 'approval_status', 1);
learndash_process_mark_complete(I am not sure what should I put here because I am not able to create a topic id);
send_email_after_assignment_approval($post_id, $teachers_comment);
$approval_message = 'Great job on your assignment! <br><b>' . $teachers_comment . '</b>' . (empty($teachers_comment) ? '' : '<br>') .
'Your submission for <b><a href="' . get_permalink($lesson_id) . '">' . $lesson_title . '</a></b> in the ' .
'<b><a href="' . get_permalink($course_id) . '">' . $course_title . '</a></b> is now approved. <br>Thanks for spending the time to get that in.';
send_new_message($student_id, $approval_message);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要两个函数来构建您的代码:
Learndash_is_assignment_approved_by_meta(检查是否批准了评估)
https://developers.learndash.com/function/learndash_is_assignment_approved_by_meta/
LearnDash_process_mark_complete(Automark完成)
https://developers.learndash.com/function/learndash_process_mark_complete/
That's an example of an我写的自动完成功能,也许可以帮助更好地了解其工作原理。
You need two functions to build your code:
learndash_is_assignment_approved_by_meta ( check if an assigment is approved )
https://developers.learndash.com/function/learndash_is_assignment_approved_by_meta/
learndash_process_mark_complete ( automark as complete )
https://developers.learndash.com/function/learndash_process_mark_complete/
That's an example of an autocomplete function I wrote, maybe it could help to better understand how it works.