1: <?php
2:
3: if ( ! defined( 'ABSPATH' ) ) exit;
4:
5: if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Quiz_Submitted' ) ) :
6:
7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class WooThemes_Sensei_Email_Teacher_Quiz_Submitted {
18:
19: var $template;
20: var $subject;
21: var $heading;
22: var $recipient;
23: var $learner;
24: var $teacher;
25:
26: 27: 28:
29: function __construct() {
30: $this->template = 'teacher-quiz-submitted';
31: $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has submitted a quiz for grading', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
32: $this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has submitted a quiz for grading', 'woothemes-sensei' ), $this->template );
33: }
34:
35: 36: 37: 38: 39: 40: 41: 42:
43: function trigger( $learner_id = 0, $quiz_id = 0 ) {
44: global $sensei_email_data;
45:
46:
47: $this->learner = new WP_User( $learner_id );
48:
49:
50: $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
51:
52: if ( ! Sensei_Utils::user_started_lesson( $lesson_id, $learner_id ) ) {
53: return;
54: }
55:
56: $course_id = get_post_meta( $lesson_id, '_lesson_course', true );
57: $teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
58: $this->teacher = new WP_User( $teacher_id );
59:
60:
61: $sensei_email_data = apply_filters( 'sensei_email_data', array(
62: 'template' => $this->template,
63: 'heading' => $this->heading,
64: 'teacher_id' => $teacher_id,
65: 'learner_id' => $learner_id,
66: 'learner_name' => $this->learner->display_name,
67: 'quiz_id' => $quiz_id,
68: 'lesson_id' => $lesson_id,
69: ), $this->template );
70:
71:
72: $this->recipient = stripslashes( $this->teacher->user_email );
73:
74:
75: Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
76: }
77: }
78:
79: endif;
80:
81: return new WooThemes_Sensei_Email_Teacher_Quiz_Submitted();