Пример #1
0
<?php

require_once 'class_course_instance.php';
// Instantiate the CourseInstance class
$courseInstance = new CourseInstance();
$courseInstance->edit_course_instance($DB_con);
Пример #2
0
<?php

require_once 'class_course_instance.php';
?>

<div class="table-responsive">
  <table class="table table-striped"> 
  	<thead>
      <tr>
        <th>Course Code</th>
        <th>Course Title</th>
        <th>Year</th>
        <th>Study Period</th>
        <th>Status</th>
        <th>Facilitator</th>
        <th>Projects Created</th>
        <th>Location</th>
<!--         <th>Action</th> -->
      </tr>
    </thead><?php 
// Instantiate the CourseInstance class
$courseInstance = new CourseInstance();
$courseInstance->view_course_instance($DB_con);
?>

	</table>
</div>
Пример #3
0
            $_SESSION['add_course_instance_error'] = "Please select a facilitator";
            header('Location: ../add_course_instance_gui.php');
        } else {
            if (empty($delivery_method)) {
                $_SESSION['add_course_instance_error'] = "Please select a delivery method";
                header('Location: ../add_course_instance_gui.php');
            } else {
                if (empty($year)) {
                    $_SESSION['add_course_instance_error'] = "Please select a year";
                    header('Location: ../add_course_instance_gui.php');
                } else {
                    if (empty($study_period)) {
                        $_SESSION['add_course_instance_error'] = "Please select a study period";
                        header('Location: ../add_course_instance_gui.php');
                    }
                }
            }
        }
    }
    // create a class object
    $course_instance = new CourseInstance();
    $course_instance . set_course_id($course_id);
    $course_instance . set_facilitator($facilitator);
    $course_instance . set_study_period($study_period);
    $course_instance . set_year($year);
    $course_instance . set_location($delivery_method);
    // check if exists
    $course_instance->check_instance_exists($DB_con);
    // add to database
    $course_instance->add_course_instance($DB_con);
}
Пример #4
0
function list_courses()
{
    global $wpdb;
    $table_name = $wpdb->prefix . "lms_instances";
    if (isset($_POST['deleteit']) && isset($_POST['delete'])) {
        check_admin_referer('bulk-courses');
        foreach ((array) $_POST['delete'] as $course_id_del) {
            if (!current_user_can('manage_courses', $course_id_del)) {
                wp_die(__('You are not allowed to delete this course.'));
            }
            $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE id = %d", $course_id_del));
        }
        echo "<div class='updated'><p>" . __('Course removed successfully', 'warp_lms') . "</p></div>";
    }
    $courses = CourseInstance::find_active();
    if ($courses) {
        ?>
		<form action="" method="post" id="courses-filter">
			<div class="tablenav">

			<div class="alignleft">
			<input type="submit" value="<?php 
        _e('Delete');
        ?>
" name="deleteit" class="button-secondary delete" />
			<?php 
        wp_nonce_field('bulk-courses');
        ?>
			</div>

			<br class="clear" />
			</div>

			<br class="clear" />

		<table class="widefat">
		  <thead>
		  <tr>
			<th class="check-column" scope="col"><input type="checkbox" onclick="checkAll(document.getElementById('courses-filter'));"/></th>
			<th scope="col"><?php 
        _e('Starts on', 'warp_lms');
        ?>
</th>
			<th scope="col"><?php 
        _e('Ends on', 'warp_lms');
        ?>
</th>
			<th scope="col"><?php 
        _e('Course Name', 'warp_lms');
        ?>
</th>
			<th scope="col"><?php 
        _e('Students', 'warp_lms');
        ?>
</th>
		  </tr>
		  </thead>
		  <tbody>
		  <?php 
        foreach ($courses as $course) {
            ?>
				<tr>
					<th class="check-column" scope="row"><input type="checkbox" value="<?php 
            echo $course->id;
            ?>
" name="delete[]" /></th>
					<td><?php 
            echo mysql2date(__('Y/m/d'), $course->start_date);
            ?>
</td>
					<td><?php 
            echo mysql2date(__('Y/m/d'), $course->end_date);
            ?>
</td>
					<td><?php 
            echo $course->course->post_title;
            ?>
</td>
					<td><?php 
            if (count($course->students) > 0) {
                echo "<a href='?page=warp_lms/students.php&course_id={$course->id}'>" . count($course->students) . "</a>";
            } else {
                echo count($course->students);
            }
            ?>
</td>
				</tr>
				<?php 
        }
        ?>
		  </tbody>
		</table>
		</form>
		<?php 
    }
}
Пример #5
0
 function find_all_by_course($course_id)
 {
     global $wpdb;
     $results = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT s.*, r.course_id \n\t\t\tFROM " . $wpdb->prefix . "lms_students s\n\t\t\tLEFT JOIN " . $wpdb->prefix . "lms_registrations r ON s.id = r.student_id\n\t\t\tLEFT JOIN " . $wpdb->prefix . "lms_instances i ON i.id = r.course_id\n\t\t\tWHERE i.id = %d\n\t\t", $course_id));
     $students = array();
     foreach ($results as $student) {
         $s = new Student($student->first_name, $student->last_name, $student->company, $student->email, $student->phone);
         $s->course = CourseInstance::find($student->course_id);
         $s->id = $student->id;
         $students[] = $s;
     }
     return $students;
 }
Пример #6
0
function lms_join_form()
{
    global $wp_query;
    $course_id = $wp_query->get('page');
    $courses = CourseInstance::find_active();
    $content .= "\n\t\t<form action='" . $_SERVER["REQUEST_URI"] . "' method='POST' class='bpform'>\n\t\t\t<fieldset>\n\t\t\t\t<legend>" . __('Student info', 'warp_lms') . "</legend>\n\t\t\t\t<label for='first_name'>" . __('First name', 'warp_lms') . "</label><input type='text' name='first_name' value='' id='first_name'  />\n\t\t\t\t<label for='last_name'>" . __('Last name', 'warp_lms') . "</label><input type='text' name='last_name' value='' id='last_name'  />\n\t\t\t\t<label for='company'>" . __('Company', 'warp_lms') . "</label><input type='text' name='company' value='' id='company'  />\n\t\t\t\t<label for='email'>" . __('Email', 'warp_lms') . "</label><input type='text' name='email' value='' id='email'  />\n\t\t\t\t<label for='confirm_email'>" . __('Confirm email', 'warp_lms') . "</label><input type='text' name='confirm_email' value='' id='confirm_email'  />\n\t\t\t\t<label for='phone'>" . __('Phone', 'warp_lms') . "</label><input type='text' name='phone' value='' id='phone'  />\n\t\t\t</fieldset>\n\t\t\t\n\t\t\t<script type='text/javascript'>\n\t\t\t\tf_fn = new LiveValidation('first_name');\n\t\t\t\tf_fn.add( Validate.Presence );\n\t\t\t\tf_ln = new LiveValidation('last_name');\n\t\t\t\tf_ln.add( Validate.Presence );\n\t\t\t\tf_co = new LiveValidation('company');\n\t\t\t\tf_co.add( Validate.Presence );\n\t\t\t\tf_em = new LiveValidation('email');\n\t\t\t\tf_em.add( Validate.Presence );\n\t\t\t\tf_em.add( Validate.Email );\n\t\t\t\tf_ce = new LiveValidation('confirm_email');\n\t\t\t\tf_ce.add( Validate.Presence );\n\t\t\t\tf_ce.add( Validate.Confirmation, { match: 'email' })\n\t\t\t\tf_ph = new LiveValidation('phone');\n\t\t\t\tf_ph.add( Validate.Presence );\n\t\t\t\t\n\t\t\t\tvar price_array = new Array();";
    foreach ($courses as $course) {
        $content .= sprintf("price_array[%d] = '%s';", $course->id, $course->price());
    }
    $content .= "\n\t\t\t\t\n\t\t\t\tfunction updatePrice(course) {\n\t\t\t\t\tjQuery('#course_price').html(price_array[course.options[course.selectedIndex].value]);\n\t\t\t\t}\n\t\t\t</script>\n\t\t\t\n\t\t\t<fieldset>\n\t\t\t\t<legend>" . __('Course info', 'warp_lms') . "</legend>\n\t\t\t\t<label for='course_id'>" . __('Course type', "warp_lms") . "</label>\n\t\t\t\t<select name='course_id' id='course_id'>";
    foreach ($courses as $course) {
        $content .= "<option value='" . $course->id . "'";
        if ($course_id == $course->id) {
            $content .= " selected='selected'";
        }
        $content .= ">" . sprintf(__('%s starting on %s', 'warp_lms'), $course->course->post_title, mysql2date(get_option('date_format'), $course->start_date)) . "</option>";
    }
    $content .= "\n\t\t\t\t</select>\n\t\t\t\t\n\t\t\t\t<label>" . __('Course price', 'warp_lms') . "</label>\n\t\t\t\t<p><span id='course_price'>" . $course->price() . "</span> " . get_option('lms_currency') . "</p>\n\t\t\t</fieldset>\n\t\t\t\n\t\t\t<script type='text/javascript'>\n\t\t\t\tjQuery('#course_id').change(function(){\n\t\t\t\t\tjQuery('#course_price').html(price_array[jQuery('#course_id option:selected').attr('value')]);\n\t\t\t\t})\n\t\t\t</script>\n\t\t\t\n\t\t\t<input type='hidden' name='action' value='register_student' id='action' />\n\t\t\t<p class='buttons'>\n\t\t        <button type='submit' class='button positive'><img src='" . get_option('siteurl') . "/wp-content/plugins/warp_lms/tick.png' alt='' /> " . __('Register for this course', 'warp_lms') . "</button>\n\t\t    </p>\n\n\t\t</form>\n\t";
    return $content;
}