Esempio n. 1
0
                            }
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            $data->metas['video_url'] = $_POST[$this->name . '_video_url'][$key];
                            $data->metas['attachment_id'] = $_POST[$this->name . '_attachment_id'][$key];
                            if (!empty($_POST[$this->name . '_player_width'])) {
                                $data->metas['player_width'] = $_POST[$this->name . '_player_width'][$key];
                            }
                            $data->metas['time_estimation'] = $_POST[$this->name . '_time_estimation'][$key];
                            //
                            // if ( isset($_POST[$this->name . '_show_title_on_front'][$key]) ) {
                            //     $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_on_front'][$key];
                            // } else {
                            //     $data->metas['show_title_on_front'] = 'no';
                            // }
                            //$data->metas['player_height'] = $_POST[$this->name . '_player_height'][$key];
                            $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                            $data->metas['show_media_caption'] = $_POST[$this->name . '_show_caption_field'][$key];
                            $data->metas['caption_custom_text'] = $_POST[$this->name . '_caption_custom_text'][$key];
                            $data->metas['caption_field'] = $_POST[$this->name . '_caption_field'][$key];
                            $data->metas['hide_related_media'] = $_POST[$this->name . '_hide_related_media_field'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('video_module', 'video_module', 'output');
Esempio n. 2
0
                    $data->title = '';
                    $data->excerpt = '';
                    $data->content = '';
                    $data->metas = array();
                    $data->metas['module_type'] = $this->name;
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            $data->content = $_POST[$this->name . '_content'][$key];
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            $data->metas['time_estimation'] = $_POST[$this->name . '_time_estimation'][$key];
                            // if ( isset($_POST[$this->name . '_show_title_on_front'][$key]) ) {
                            //     $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_on_front'][$key];
                            // } else {
                            //     $data->metas['show_title_on_front'] = 'no';
                            // }
                            $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('text_module', 'text_module', 'output');
Esempio n. 3
0
                        $data->unit_id = '';
                        $data->title = '';
                        $data->excerpt = '';
                        $data->content = '';
                        $data->metas = array();
                        $data->metas['module_type'] = $this->name;
                        $data->post_type = 'module';
                        if (isset($_POST[$this->name . '_id'])) {
                            foreach ($_POST[$this->name . '_id'] as $key => $value) {
                                $data->ID = $_POST[$this->name . '_id'][$key];
                                $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                                $data->title = $_POST[$this->name . '_title'][$key];
                                $data->content = $_POST[$this->name . '_content'][$key];
                                $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                                $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                                // if ( isset($_POST[$this->name . '_show_title_on_front'][$key]) ) {
                                //     $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_on_front'][$key];
                                // } else {
                                //     $data->metas['show_title_on_front'] = 'no';
                                // }
                                $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                                parent::update_module($data);
                            }
                        }
                    }
                }
            }
        }
    }
    cp_register_module('chat_module', 'chat_module', 'output');
}
                        $response_value = strip_tags($response_value);
                        $response_value = htmlentities($response_value);
                        $data->content = $response_value;
                        /* CHECK AND SET THE GRADE AUTOMATICALLY */
                        $checked_value = get_post_meta($response_id, 'checked_answer', true);
                        $checked_value = stripslashes($checked_value);
                        $checked_value = strip_tags($checked_value);
                        $checked_value = htmlentities($checked_value);
                        if ($data->content == $checked_value) {
                            $response_grade = 100;
                        } else {
                            $response_grade = 0;
                        }
                        $data->auto_grade = $response_grade;
                        // Record mandatory question answered
                        $mandatory_answer = get_post_meta($response_id, 'mandatory_answer', true);
                        $unit_id = (int) $_POST['unit_id'];
                        if (!empty($mandatory_answer) && 'yes' == $mandatory_answer) {
                            $course_id = get_post_meta($unit_id, 'course_id', true);
                            Student_Completion::record_mandatory_answer(get_current_user_id(), $course_id, $unit_id, $response_id);
                        }
                        $data->module_id = $response_id;
                        parent::update_module_response($data);
                    }
                }
            }
        }
    }
}
cp_register_module('radio_input_module', 'radio_input_module', 'input');
Esempio n. 5
0
                    $data->excerpt = '';
                    $data->content = '';
                    $data->metas = array();
                    $data->metas['module_type'] = $this->name;
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            $data->metas['link_text'] = $_POST[$this->name . '_link_text'][$key];
                            $data->metas['file_url'] = $_POST[$this->name . '_file_url'][$key];
                            $data->metas['time_estimation'] = $_POST[$this->name . '_time_estimation'][$key];
                            // if ( isset($_POST[$this->name . '_show_title_on_front'][$key]) ) {
                            //     $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_on_front'][$key];
                            // } else {
                            //     $data->metas['show_title_on_front'] = 'no';
                            // }
                            $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('file_module', 'file_module', 'output');
                            $filename = $movefile['file'];
                            $wp_upload_dir = wp_upload_dir();
                            $attachment = array('guid' => $movefile['url'], 'post_mime_type' => $movefile['type'], 'post_title' => basename($movefile['url']), 'post_content' => '', 'post_status' => 'inherit');
                            $attach_id = wp_insert_attachment($attachment, $filename, $response_id);
                            $post_ancestors = get_post_ancestors($response_id);
                            $unit_id = $post_ancestors[0];
                            $course_id = get_post_meta($unit_id, 'course_id', true);
                            update_post_meta($attach_id, 'user_ID', get_current_user_ID());
                            update_post_meta($attach_id, 'course_id', $course_id);
                            // Record mandatory question answered
                            $mandatory_answer = get_post_meta($response_id, 'mandatory_answer', true);
                            if (!empty($mandatory_answer) && 'yes' == $mandatory_answer) {
                                Student_Completion::record_mandatory_answer(get_current_user_id(), $course_id, $unit_id, $response_id);
                            }
                        } else {
                            ?>
							<p class="form-info-red"><?php 
                            echo $movefile['error'];
                            ?>
</p>
						<?php 
                        }
                    } else {
                    }
                }
            }
        }
    }
}
cp_register_module('file_input_module', 'file_input_module', 'input');
Esempio n. 7
0
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            //cp_write_log($key);
                            // cp_write_log($_POST[$this->name . '_autoplay'][$_POST[$this->name . '_module_order']]);
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            //$data->content = $_POST[$this->name . '_content'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['audio_url'] = $_POST[$this->name . '_audio_url'][$key];
                            $data->metas['autoplay'] = $_POST[$this->name . '_autoplay'][$data->metas['module_order']];
                            $data->metas['loop'] = $_POST[$this->name . '_loop'][$data->metas['module_order']];
                            $data->metas['time_estimation'] = $_POST[$this->name . '_time_estimation'][$key];
                            // if ( isset($_POST[$this->name . '_show_title_on_front'][$key]) ) {
                            //     $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_on_front'][$key];
                            // } else {
                            //     $data->metas['show_title_on_front'] = 'no';
                            // }
                            $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('audio_module', 'audio_module', 'output');
Esempio n. 8
0
                    $data->title = '';
                    $data->excerpt = '';
                    $data->content = '';
                    $data->metas = array();
                    $data->metas['module_type'] = $this->name;
                    // $data->metas['show_media_caption'] = array();
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            $data->metas['image_url'] = $_POST[$this->name . '_image_url'][$key];
                            $data->metas['attachment_id'] = $_POST[$this->name . '_attachment_id'][$key];
                            $data->metas['time_estimation'] = $_POST[$this->name . '_time_estimation'][$key];
                            $data->metas['show_title_on_front'] = $_POST[$this->name . '_show_title_field'][$key];
                            $data->metas['show_media_caption'] = $_POST[$this->name . '_show_caption_field'][$key];
                            $data->metas['caption_custom_text'] = $_POST[$this->name . '_caption_custom_text'][$key];
                            $data->metas['caption_field'] = $_POST[$this->name . '_caption_field'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('image_module', 'image_module', 'output');
                    $response_id = intval(str_replace($this->name . '_front_', '', $response_name));
                    if ($response_value != '') {
                        $data = new stdClass();
                        $data->ID = '';
                        $data->title = '';
                        $data->excerpt = '';
                        $data->content = '';
                        $data->metas = array();
                        $data->metas['user_ID'] = get_current_user_id();
                        $data->post_type = 'module_response';
                        $data->response_id = $response_id;
                        $data->title = '';
                        //__( 'Response to '.$response_id.' module ( Unit '.$_POST['unit_id'].' )' );
                        $data->content = $response_value;
                        // Record mandatory question answered
                        $mandatory_answer = get_post_meta($response_id, 'mandatory_answer', true);
                        $unit_id = (int) $_POST['unit_id'];
                        if (!empty($mandatory_answer) && 'yes' == $mandatory_answer) {
                            $course_id = get_post_meta($unit_id, 'course_id', true);
                            Student_Completion::record_mandatory_answer(get_current_user_id(), $course_id, $unit_id, $response_id);
                        }
                        $data->module_id = $response_id;
                        parent::update_module_response($data);
                    }
                }
            }
        }
    }
}
cp_register_module('text_input_module', 'text_input_module', 'input');
        global $wpdb, $last_inserted_unit_id, $save_elements;
        if (isset($_POST['module_type']) && $save_elements == true) {
            foreach (array_keys($_POST['module_type']) as $module_type => $module_value) {
                if ($module_value == $this->name) {
                    $data = new stdClass();
                    $data->ID = '';
                    $data->unit_id = '';
                    $data->title = '';
                    $data->excerpt = '';
                    $data->content = '';
                    $data->metas = array();
                    $data->metas['module_type'] = $this->name;
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            $data->content = '';
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('section_break_module', 'section_break_module', 'output');
                                if (in_array($chosen_answer, $right_answers)) {
                                    $response_grade = $response_grade + 100;
                                } else {
                                    //$response_grade = $response_grade + 0;//this line can be empty as well : )
                                }
                            }
                            if (count($chosen_answers) >= count($right_answers)) {
                                $grade_cnt = count($chosen_answers);
                            } else {
                                $grade_cnt = count($right_answers);
                            }
                            $response_grade = round($response_grade / $grade_cnt, 0);
                            $data->auto_grade = $response_grade;
                        }
                        // Record mandatory question answered
                        $mandatory_answer = get_post_meta($response_id, 'mandatory_answer', true);
                        $unit_id = (int) $_POST['unit_id'];
                        if (!empty($mandatory_answer) && 'yes' == $mandatory_answer) {
                            $course_id = get_post_meta($unit_id, 'course_id', true);
                            Student_Completion::record_mandatory_answer(get_current_user_id(), $course_id, $unit_id, $response_id);
                        }
                        $data->module_id = $response_id;
                        parent::update_module_response($data);
                    }
                }
            }
        }
    }
}
cp_register_module('checkbox_input_module', 'checkbox_input_module', 'input');
Esempio n. 12
0
        if (isset($_POST['module_type']) && $save_elements == true) {
            foreach (array_keys($_POST['module_type']) as $module_type => $module_value) {
                if ($module_value == $this->name) {
                    $data = new stdClass();
                    $data->ID = '';
                    $data->unit_id = '';
                    $data->title = '';
                    $data->excerpt = '';
                    $data->content = '';
                    $data->metas = array();
                    $data->metas['module_type'] = $this->name;
                    $data->post_type = 'module';
                    if (isset($_POST[$this->name . '_id'])) {
                        foreach ($_POST[$this->name . '_id'] as $key => $value) {
                            $data->ID = $_POST[$this->name . '_id'][$key];
                            $data->unit_id = (isset($_POST['unit_id']) and isset($_POST['unit']) && $_POST['unit'] != '') ? $_POST['unit_id'] : $last_inserted_unit_id;
                            $data->title = $_POST[$this->name . '_title'][$key];
                            $data->content = '';
                            //$_POST[$this->name . '_content'][$key];
                            $data->metas['module_order'] = $_POST[$this->name . '_module_order'][$key];
                            $data->metas['module_page'] = $_POST[$this->name . '_module_page'][$key];
                            parent::update_module($data);
                        }
                    }
                }
            }
        }
    }
}
cp_register_module('page_break_module', 'page_break_module', 'invisible');