예제 #1
0
 function test_delete()
 {
     //Arrange
     $name = "Shmuel Irving-Jones";
     $enroll_date = "2015-08-25";
     $test_student = new Student($name, $enroll_date);
     $test_student->save();
     $name2 = "Billy Bartle-Barnaby";
     $enroll_date2 = "2015-07-09";
     $test_student2 = new Student($name2, $enroll_date2);
     $test_student2->save();
     //Act
     $test_student->delete();
     //Assert
     $result = Student::getAll();
     $this->assertEquals($test_student2, $result[0]);
 }
예제 #2
0
<!doctype html>
<html>
<?php 
include 'config/database.php';
include 'object/student.php';
//make a database object:
$database = new Database();
//make it connect:
$conn = $database->getConnection();
// instantiate a new student object
$student = new Student($conn);
if (isset($_GET['deleteid'])) {
    //if there is a delete id, it sets the Student ID to it
    $student->stud_id = $_GET['deleteid'];
    //Then runs function delete
    $stmt = $student->delete();
}
?>

<head>
    <meta charset="utf-8">
    <title>Community Service</title>
    <link href='https://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
    <!-- <link rel="stylesheet" type="text/css" href="css/app.css"> -->
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="icon" type="image/ico" href="images/favicon.ico">
</head>

<body class="clearfix">
    <div class="content_div">
        <div class="msg-container">
 function testDelete()
 {
     $name = "Bob";
     $enrollment_date = "2015-01-01";
     $test_student = new Student($name, $enrollment_date);
     $test_student->save();
     $name = "History";
     $course_number = "HIST100";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     //act
     $test_student->addCourse($test_course);
     $test_student->delete();
     $this->assertEquals([], $test_student->getCourses());
 }
예제 #4
0
<?php

require_once 'classes/Entity/Student.php';
require_once 'classes/View.php';
require_once 'classes/Data.php';
if (isset($_GET['del_id'])) {
    Student::delete($_GET['del_id']);
}
$students = Student::findAll();
Data::setData('students', $students);
View::render('students');
예제 #5
0
function showStudent()
{
    global $connector;
    global $result;
    $student = new Student();
    $course = new Course();
    $plan = new Plan();
    $student->setConnector($connector);
    $course->setConnector($connector);
    $plan->setConnector($connector);
    if (isset($_POST['operation'])) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'delete':
                $error_msg = $student->delete($params);
                break;
            case 'edit':
                $stud = $student->getById($params);
                $result['edit'] = $stud;
                $result['edit']->student = $stud;
                $exam = new Exam();
                $exam->setConnector($connector);
                $result['edit']->exam = $exam->getList($result['edit']->student);
                break;
            case 'editChanges':
                $student->storeFormValues($_POST);
                $error_msg = $student->update();
                break;
            case 'saveChanges':
                $student->storeFormValues($_POST);
                $error_msg = $student->insert();
                if ($error_msg) {
                    $result['edit'] = $student;
                }
                break;
            case 'nextPage':
                $student->storeFormValues($_POST);
                $result['edit'] = $student;
                break;
            case 'createPassword':
                $stud = $student->getById($params);
                $stud->setConnector($connector);
                $error_msg = $stud->generatePassword();
                $result['edit'] = $stud;
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit' && $operation != "nextPage") {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    if (isset($_POST['search'])) {
        $result["students"] = $student->search($_POST['search']);
    } else {
        $result["students"] = $student->getList();
    }
    $result["plans"] = $plan->getList("id_piano");
    $result["courses"] = $course->getList("nome");
    $page = "student.php";
    include_once BASE_PATH . "template.php";
}
예제 #6
0
 public static function delete($id)
 {
     session_start();
     $headers = apache_request_headers();
     $token = $headers['X-Auth-Token'];
     if (!$headers['X-Auth-Token']) {
         header('Invalid CSRF Token', true, 401);
         return print json_encode(array('success' => false, 'status' => 400, '1msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
         die;
     } else {
         if ($token != $_SESSION['form_token']) {
             header('Invalid CSRF Token', true, 401);
             return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
             die;
         } else {
             Student::delete($id);
         }
     }
 }
예제 #7
0
 function test_delete()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $name = "Ashlin Aronin";
     $enrollment_date = "2015-08-24";
     $test_student = new Student($name, $enrollment_date, $test_department->getId());
     $test_student->save();
     $name2 = "John Nolastname";
     $enrollment_date2 = "2015-07-20";
     $test_student2 = new Student($name, $enrollment_date, $test_department->getId());
     $test_student2->save();
     //Act
     $test_student->delete();
     //Assert
     $result = Student::getAll();
     $this->assertEquals([$test_student2], $result);
 }
 function testDeleteStudent()
 {
     //Arrange
     $id = null;
     $name = "Micah";
     $enrollment_date = "2015-08-28";
     $test_student = new Student($id, $name, $enrollment_date);
     $test_student->save();
     $name2 = "Intro to History";
     $number = "HIST100";
     $test_course = new Course($id, $name2, $number);
     $test_course->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Act
     $this->assertEquals([], $test_course->getStudents());
 }
예제 #9
0
<?php

require_once "../init.php";
$student = new Student(new PDOdb("mysql:host=localhost;dbname=usjr", "root", ""));
$studid = $_POST['stid'];
$studfname = $_POST['stfname'];
$studmname = $_POST['stmname'];
$studlname = $_POST['stlname'];
$studcourse = $_POST['stcourse'];
$studyear = $_POST['styear'];
$result = $student->delete(array('studid'), array($studid));
// if($result > 0)
// 	 echo "Data added";
// else
//      echo "Data was not added";
header("Location:studentDeleteList.php");
예제 #10
0
 public function delete()
 {
     $this->output->set_content_type('application/json');
     $this->usermanager->teacher_login_protected_redirect();
     $url = $this->uri->ruri_to_assoc(3);
     $student_id = isset($url['student_id']) ? intval($url['student_id']) : 0;
     if ($student_id != 0) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $student = new Student();
         $student->get_by_id($student_id);
         $student->delete();
         if ($this->db->trans_status()) {
             $this->db->trans_commit();
             $this->output->set_output(json_encode(TRUE));
         } else {
             $this->db->trans_rollback();
             $this->output->set_output(json_encode(FALSE));
         }
     } else {
         $this->output->set_output(json_encode(FALSE));
     }
 }
예제 #11
0
function doDelete()
{
    @($id = $_POST['selector']);
    $key = count($id);
    //multi delete using checkbox as a selector
    for ($i = 0; $i < $key; $i++) {
        $student = new Student();
        $student->delete($id[$i]);
        $details = new Student_details();
        $details->delete($id[$i]);
        $sy = new Schoolyr();
        $sy->delete($id[$i]);
        $req = new Requirements();
        $req->delete($id[$i]);
    }
    message("Student has successfully deleted!", "info");
    redirect('index.php');
}
 function testDelete()
 {
     $student_name = "John Doe";
     $enrollment_date = "2015-09-01";
     $test_student = new Student($student_name, $enrollment_date);
     $test_student->save();
     $student_name2 = "Jane Smith";
     $enrollment_date2 = "2013-09-01";
     $test_student2 = new Student($student_name, $enrollment_date);
     $test_student2->save();
     $test_student->delete();
     $this->assertEquals([$test_student2], Student::getAll());
 }
예제 #13
0
 function testDelete()
 {
     //Arrange
     $name = "Rick";
     $date = "2015-08-15";
     $id = 1;
     $test_student = new Student($name, $date, $id);
     $test_student->save();
     //Act
     $test_student->delete();
     $result = Student::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
예제 #14
0
 function test_delete()
 {
     //Arange
     $name = "Steve Beekman";
     $date = "2015-08-23";
     $test_student = new Student($name, $date);
     $test_student->save();
     $name2 = "Fred Flintstone";
     $date2 = "0001-01-01";
     $test_student2 = new Student($name2, $date2);
     $test_student2->save();
     //Act
     $test_student->delete();
     $result = Student::getAll();
     //Assert
     $this->assertEquals([$test_student2], $result);
 }
 function test_deleteStudent()
 {
     //Arrange
     $student_name = "Joker";
     $enrollment_date = "6000-12-14";
     $id = 1;
     $student = new Student($student_name, $enrollment_date, $id);
     $student->save();
     $student_name2 = "Riddler";
     $enrollment_date2 = "7000-08-09";
     $id2 = 2;
     $student2 = new Student($student_name2, $enrollment_date2, $id2);
     $student2->save();
     //Act
     $student->delete();
     //Assert
     $this->assertEquals([$student2], Student::getAll());
 }
예제 #16
0
 function testDelete()
 {
     //Arrange
     $name = "Biology 101";
     $number = 101;
     $id = 1;
     $test_course = new Course($name, $number, $id);
     $test_course->save();
     $name = "Elliot Michaels";
     $date = "2015-08-03";
     $id = 1;
     $test_student = new Student($name, $date, $id);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
예제 #17
0
 function testDelete()
 {
     //Arrange
     $name = "Ben";
     $enroll_date = "0000-00-00";
     $id = 1;
     $test_student = new Student($name, $enroll_date, $id);
     $test_student->save();
     $course_name = "Intro to Art";
     $course_number = "ART101";
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
 function testDelete()
 {
     $name = "Math";
     $date = '0000-00-00';
     $id = null;
     $test_course = new Course($name, $id);
     $test_course->save();
     $student_name = "Student1";
     $course_id = $test_course->getId();
     $test_student = new Student($student_name, $id, $date, $course_id);
     $test_student->save();
     $test_student->addCourse($test_course);
     $test_student->delete();
     $this->assertEquals([], $test_course->getStudents());
 }
예제 #19
0
 function testDelete()
 {
     //Arrange
     $name = "Biology 101";
     $number = 101;
     $id = 1;
     $test_course = new Course($name, $number, $id);
     $test_course->save();
     $name = "Auto";
     $number2 = 101;
     $id2 = 2;
     $test_student = new Student($name, $date, $id2);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }