LLMS_Abstract_Notification_View_Quiz_Completion::set_merge_data( string $code )

Replace merge codes with actual values


Parameters Parameters

$code

(string) (Required) The merge code to get merged data for.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/abstracts/llms.abstract.notification.view.quiz.completion.php

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
protected function set_merge_data( $code ) {
 
    $quiz_id = $this->notification->get( 'post_id' );
    $attempt = $this->user->quizzes()->get_last_completed_attempt( $quiz_id );
    if ( ! $attempt ) {
        return '';
    }
    $lesson = llms_get_post( $attempt->get( 'lesson_id' ) );
    if ( ! $lesson ) {
        return '';
    }
 
    switch ( $code ) {
 
        case '{{COURSE_TITLE}}':
            $course = $lesson->get_course();
            if ( $course ) {
                $code = $course->get( 'title' );
            } else {
                $code = '';
            }
            break;
 
        case '{{GRADE}}':
            $code = round( $attempt->get( 'grade' ), 2 ) . '%';
            break;
 
        case '{{GRADE_BAR}}':
            $code = lifterlms_course_progress_bar( $attempt->get( 'grade' ), false, false, false );
            break;
 
        case '{{LESSON_TITLE}}':
            $code = $lesson->get( 'title' );
            break;
 
        case '{{QUIZ_TITLE}}':
            $code = get_the_title( $quiz_id );
            break;
 
        case '{{REVIEW_URL}}':
            $code = add_query_arg(
                array(
                    'tab'        => 'quizzes',
                    'stab'       => 'attempts',
                    'quiz_id'    => $attempt->get( 'quiz_id' ),
                    'attempt_id' => $attempt->get( 'id' ),
                ),
                admin_url( 'admin.php?page=llms-reporting' )
            );
            break;
 
        case '{{STATUS}}':
            $code = $attempt->l10n( 'status' );
            break;
 
        case '{{STUDENT_NAME}}':
            $code = $this->is_for_self() ? __( 'you', 'lifterlms' ) : $this->user->get_name();
            break;
 
    }
 
    return $code;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
4.0.0 Remove usage of deprecated class LLMS_Quiz_Legacy.
3.24.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.