public function go()
 {
     $this->setViewTemplate('addclass.tpl');
     if (isset($_POST['submit'])) {
         if ($_POST['classname'] == '') {
             $this->addErrorMessage("Name of the class should not be empty");
         } else {
             // $this->created_by= Session::getLoggedInUser();
             $classname = $_POST['classname'];
             $date_created = date("Y-m-d H:i:s");
             if (Classes::doesClassExist($classname)) {
                 $this->addErrorMessage(" This Classname already exists");
             } else {
                 Classes::addClass($classname, $date_created);
                 header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/manageclass.php?source=addclass");
             }
         }
     }
     $this->generateView();
 }
Esempio n. 2
0
//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");
//construct empty class
$class = new Classes();
//add a class
$class->addClass("Calculus I", "Math");
unset($class);
//get class from db
$class2 = new Classes("Calculus I");
//get subject for class
$my_subject = $class2->getSubject();
printf("Calculus I subject is: %s\n", $my_subject);
//get A to Z class list
$orderedArray = $class2->getAZClassList();
printf("Ordered Classes: \n");
foreach ($orderedArray as $class_val) {
    printf("%s\n", $class_val);
}
//get A to Z class list for specific subject
$orderedArray = $class2->getClassBySubject("Math");
printf("Ordered Classes by Subject - Math: \n");
Esempio n. 3
0
$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)
if ($ext == 'pdf' || $ext == 'ods' || $ext == 'odp' || $ext == 'odt') {
    //file that is uploaded is a temporary file.  Need to copy the temp file to correct location
    if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file " . basename($_FILES['uploadedfile']['name']) . " has been uploaded";
    } else {
        echo "There was an error uploading the file, please try again!";
    }