Ejemplo n.º 1
0
        }
    } else {
        if ($_GET['action'] == 'enroll') {
            try {
                if ($_GET['id'] == 'all') {
                    $students = SajjelStudent::findall();
                    foreach ($students as $student) {
                        if ($student->getEnrollmentId()) {
                            continue;
                        }
                        $res = $student->enroll();
                    }
                } else {
                    $student = SajjelStudent::find($_GET['id']);
                    $res = $student->enroll();
                }
                if ($res) {
                    $message_success = "Student had been enrolled into the moodle course sucessfully";
                } else {
                    $message_error = "Student hadn't been enrolled";
                }
            } catch (Exception $e) {
                $message_error = $e->getMessage();
            }
        }
    }
}
global $students_list;
$students_list = SajjelStudent::findall();
// Render the students list view
require dirname(__FILE__) . '/../views/students.php';
Ejemplo n.º 2
0
 */
require_once dirname(__FILE__) . '/login.php';
require_once dirname(__FILE__) . '/../models/students.php';
global $register_form;
$register_form = true;
global $register_error;
$register_error = null;
global $register_success;
$register_success = false;
global $title;
$title = "Registration Form";
if (isset($_POST['register_student'])) {
    // Collect Input from the user form
    $new_user = array('username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['password'], 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'phone1' => $_POST['phone1'], 'phone2' => $_POST['phone2'], 'address' => $_POST['address'], 'city' => $_POST['city'], 'country' => $_POST['country']);
    // Create new student
    $student = new SajjelStudent();
    $student->username = $new_user['username'];
    $student->email = $new_user['email'];
    $student->password = $new_user['password'];
    $student->firstname = $new_user['firstname'];
    $student->lastname = $new_user['lastname'];
    $student->phone1 = $new_user['phone1'];
    $student->phone2 = $new_user['phone2'];
    $student->address = $new_user['address'];
    $student->city = $new_user['city'];
    $student->country = $new_user['country'];
    try {
        $student->save();
        $register_form = false;
        $register_success = true;
    } catch (Exception $e) {