Example #1
0
session_start();
//import files
foreach (glob("apps/studyhall/models/*.php") as $filename) {
    include_once $filename;
}
$subject = $_POST['subject'];
$class = $_POST['class'];
$name = $_POST['name'];
$snf = $_POST['subject_not_found'];
$cnf = $_POST['class_not_found'];
if ($subject == "Subject Not Listed") {
    //for now assume that subject that is input is not a folder
    $subject = $snf;
    mkdir("apps/studyhall/Documents/" . $subject, 0777);
    $add_subject = new Subject();
    $add_subject->addSubject($subject);
}
if ($class == "Class Not Listed") {
    //same as above
    $class = $cnf;
    mkdir("apps/studyhall/Documents/" . $subject . "/" . $class, 0777);
    $add_class = new Classes();
    $add_class->addClass($class, $subject);
}
//this is the path created to place the document in the correct folder
$target_path = "apps/studyhall/Documents/" . $subject . "/" . $class . "/";
//this adds the file name and extension to the end of the path
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
$ext = pathinfo($target_path, PATHINFO_EXTENSION);
//echo $ext;
//only certain file types can be uploaded (constraint from ViewerJS)
Example #2
0
$user2->unblock();
$isBlocked2 = $user2->isBlocked();
$bool_str2 = $isBlocked2 ? "true" : "false";
printf("User is blocked: %s\n", $bool_str2);
unset($user);
unset($user2);
////////////////////////////
//Subject UNIT TESTS
////////////////////////////
printf("/////////////////////////////////\n");
printf("STARTING Subject UNIT TESTS\n");
printf("/////////////////////////////////\n");
//construct subject
$subject = new Subject();
//add subject
$subject->addSubject("Math");
//get subject
$subject_string = $subject->getSubject();
printf("Got Subject: %s\n", $subject_string);
//get AZSubjectArray
$orderedArray = $subject->getAZSubjects();
printf("Ordered Subjects: \n");
foreach ($orderedArray as $subject_val) {
    printf("%s\n", $subject_val);
}
////////////////////////////
//Classes UNIT TESTS
////////////////////////////
printf("/////////////////////////////////\n");
printf("STARTING Classes UNIT TESTS\n");
printf("/////////////////////////////////\n");
Example #3
0
    $app->render('admin/addClass.php');
})->name('addClass');
$app->post('/addClass', function () use($app) {
    $result = StudentClass::addClass($_POST['className']);
    $app->redirect($app->urlFor('gestionClass'));
});
$app->get('/delClass/:classId', function ($classId) use($app) {
    $result = StudentClass::delClass($classId);
    $app->redirect($app->urlFor('gestionClass'));
});
$app->get('/addSubject', function () use($app) {
    $allteacher = User::listTeacher();
    $app->render('admin/addSubject.php', array('allteacher' => $allteacher));
})->name('addSubject');
$app->post('/addSubject', function () use($app) {
    Subject::addSubject($_POST['subjectName'], $_POST['teacherId']);
    $app->redirect($app->urlFor('gestionSubject'));
});
$app->get('/delSubject/:sucjectId', function ($subjectId) use($app) {
    $result = Subject::delSubject($subjectId);
    $app->redirect($app->urlFor('gestionSubject'));
});
$app->get('/gestionSubject', function () use($app) {
    $allsubject = Subject::getAllSubject();
    $allteacher = User::listTeacher();
    $tab = array();
    $i = 0;
    $size = sizeof($allteacher);
    while ($i < $size) {
        $tab[$allteacher[$i]['teacherId']] = $allteacher[$i]['mail'];
        $i++;