function doEdit() { $courseid = $_GET['id']; $singledept = new Course(); $object = $singledept->single_course($courseid); if (isset($_POST['savecourse'])) { if ($_POST['coursename'] == "" or $_POST['coursedesc'] == "") { message("All field is required!", "error"); } else { $course = new Course(); $courseid = $_GET['id']; $coursename = $_POST['coursename']; $courselevel = $_POST['level']; $coursemajor = $_POST['major']; $coursedesc = $_POST['coursedesc']; $coursedept = $_POST['dept']; $course->COURSE_NAME = $coursename; $course->COURSE_LEVEL = $courselevel; $course->COURSE_MAJOR = $coursemajor; $course->COURSE_DESC = $coursedesc; $course->DEPT_ID = $coursedept; $course->update($courseid); message($coursename . " has updated successfully!", "info"); redirect('index.php'); } } }
function test_update() { $name = "Western Civ"; $number = "HST 101"; $test_course = new Course($name, $number); $test_course->save(); $new_name = "Eastern Meds"; $test_course->update($new_name); $this->assertEquals("Eastern Meds", $test_course->getName()); }
function testUpdate() { $name = "History"; $course_number = "HIST100"; $test_course = new Course($name, $course_number); $test_course->save(); $new_name = "Home Economics"; $test_course->update($new_name, $course_number); $this->assertEquals($new_name, $test_course->getName()); }
function testUpdate() { //Arrange $id = 1; $name = "History"; $number = 101; $test_course = new Course($name, $number, $id); $test_course->save(); //Act $new_name = "Auto"; $test_course->update($new_name); //Assert $this->assertEquals("Auto", $test_course->getName()); }
function testUpdate() { //Arrange $course_name = "Intro to Art"; $course_number = "ART101"; $id = 1; $test_course = new Course($course_name, $course_number, $id); $test_course->save(); //Act $new_course_name = "Intro to Fine Arts"; $test_course->update($new_course_name); //Assert $this->assertEquals("Intro to Fine Arts", $test_course->getCourseName()); }
function save() { $id = array_shift($this->param); Security::checkEditor($id); $translator = new Translator(); $obj = new Course(); try { $data = array('name' => '', 'category_id' => 0, 'format_id' => 0, 'prerequisites' => '', 'language' => 0, 'describe' => '', 'skills' => '', 'duration' => 0, 'equipment' => '', 'min' => 0, 'max' => 0, 'author' => '', 'questions' => 0, 'active' => 'false', 'exam' => 'false', 'need_approve' => 'false', 'exam_duration' => 0); foreach ($data as $key => $val) { if (isset($_POST[$key])) { $data[$key] = $_POST[$key]; } } $data['updated'] = date('Y-m-d H:i:s', time()); $data['category_name'] = $obj->getCategoryName($data['category_id']); $obj->update($id, $data); if (isset($_FILES['file'])) { $this->uploadFiles($id); } echo <<<EOF <div class="container"> <div class="page-header"> <h1>{$translator->Course_updated}</h1> </div> <p class="lead">{$translator->Course_updated_Desc}</p> <p >{$translator->Error_Backadmincourses}</p> </div> <script type="text/javascript"> //window.location.href='/admin_courses'; </script> EOF; } catch (Exception $e) { echo <<<EOF <div class="container"> <div class="page-header"> <h1>{$translator->Course_error}</h1> </div> <p class="lead">{$translator->Course_error_Desc}</p> {$e} <p >{$translator->Error_Backadmincourses}</p> </div> EOF; } }
public static function update($courseid) { $params = $_POST; $params['courseid'] = $courseid; $course_params = array('courseid' => $courseid, 'name' => $params['name'], 'city' => $params['city']); $course = new Course($course_params); $errors = $course->errors(); // Check hole validity before saving anything $holes = Hole::course_holes($courseid); foreach ($holes as $hole) { $hole->par = $params['hole' . $hole->hole_num]; $errors = array_merge($errors, $hole->errors()); } if (count($errors) == 0) { // Course and holes were all valid $course->update(); foreach ($holes as $hole) { $hole->update(); } Redirect::to('/course/' . $courseid, array('message' => 'Rata ja sen väylät päivitetty.')); } else { View::make('course/edit.html', array('errors' => $errors, 'attributes' => $params, 'hole_count' => $params['hole_count'])); } }
function test_update() { //Arrange $title = "Intro to Typing: COM-91"; $teacher = "Ancient Raven"; $time = "TH 9PM-11PM"; $semester = "Fall"; $test_course = new Course($title, $teacher, $time, $semester); $test_course->save(); $title2 = "Intro to Ladders: SHOP-10"; $teacher2 = "Jeff Winger"; $time2 = "MWF 11AM-12PM"; $semester2 = "Spring"; $test_course->update($title2, $teacher2, $time2, $semester2); //Act $id = $test_course->getId(); $result = new Course($title2, $teacher2, $time2, $semester2, $id); //Assert $this->assertEquals(Course::find($id), $result); }
function testUpdate() { //Arrange $name = "Math"; $id = 1; $test_course = new Course($name, $id); $test_course->save(); $new_name = "Science"; //Act $test_course->update($new_name); //Assert $this->assertEquals("Science", $test_course->getName()); }
function test_update() { $course_name = "History"; $course_number = "HIST 101"; $test_course = new Course($course_name, $course_number); $test_course->save(); $column_to_update = "course_name"; $new_course_name = "Intro to History"; $test_course->update($column_to_update, $new_course_name); $result = Course::getAll(); $this->assertEquals("Intro to History", $result[0]->getCourseName()); }
function testUpdate() { //Arrange $name = "Coding 101"; $id = 1; $test_course = new Course($name, $id); $test_course->save(); $new_name = "Advanced Coding"; //Act $test_course->update($new_name); //Assert $this->assertEquals("Advanced Coding", $test_course->getName()); }
$url = 'index.php?file=Courses&AX=Yes' . $qs . '&var_msg=' . $msg; header("Location:" . $url); exit; } else { if ($mode == "Update") { $update_sql = "UPDATE CourseClasses SET eStatus = '" . $eStatus . "'\n\t\t\tWHERE iCourseId IN(" . $iCourseId . ")"; #echo $update_sql;exit; $obj->sql_query($update_sql); $sql_check = "SELECT eStatus FROM Course WHERE iCourseId='" . $iCourseId . "' "; $check_status = $obj->select($sql_check); $check = $check_status[0]['eStatus']; if ($check == 'Inactive' && $eStatus == "Active") { $user_emails = $userObj->getNotificationUsers($iSGroupId); if (is_Array($user_emails) && count($user_emails) > 0) { for ($i = 0; $i < count($user_emails); $i++) { $sql_insert = "INSERT INTO `cron_email` (`vEmail` ,`vUsername` ,`vName` ,`vAdmin_email` ,`vCategoryName` ,`eType` ,`iID`)\n\t\t\t\t\tVALUES ('" . $user_emails[$i]['vEmail'] . "', '" . $user_emails[$i]['vUsername'] . "', '" . $vCoursename . "', '" . $user_emails['admin_email'] . "', '', 'Course', '" . $iCourseId . "')"; //echo $sql_insert;exit; $id = $obj->insert($sql_insert); // $emailObj->send_add_coursemail($user_emails[$i]['vUsername'],$vCoursename,$user_emails['admin_email'],$user_emails[$i]['vEmail']); } } } $courseObj->setdCourseDateTime($dCourseDateTime); $courseObj->setiSGroupId($iSGroupId); $courseObj->update($iCourseId); $msg = MSG_UPDATE; $url = 'index.php?file=Courses&AX=Yes' . $qs . '&var_msg=' . $msg; header("Location:" . $url); exit; } }
function testUpdate() { //Arrange $name = "Math"; $course_num = "101"; $id = 1; $test_course = new Course($name, $course_num, $id); $test_course->save(); $new_name = "English"; $new_course_num = "200"; //Act $test_course->update($new_name, $new_course_num); //Assert $this->assertEquals("English", $test_course->getName()); $this->assertEquals("200", $test_course->getCourseNum()); }
function testUpdateCourse() { //Arrange $id = null; $name = "Intro to Math"; $number = "MATH100"; $test_course = new Course($id, $name, $number); $test_course->save(); $name2 = "Math for Dummies"; $number2 = "MATH000"; //Act $test_course->update($name2, $number2); //Assert $this->assertEquals($name2, $test_course->getName()); $this->assertEquals($number2, $test_course->getNumber()); }
function showCourse() { global $connector; $page = "course.php"; $course = new Course(); $course->setConnector($connector); if ($_POST['operation']) { list($operation, $params) = explode("#", $_POST['operation']); switch ($operation) { case 'saveChanges': $course->storeFormValues($_POST); $error_msg = $course->insert(); if ($error_msg) { $result['edit'] = $course; } break; case 'delete': $error_msg = $course->delete($params); break; case 'edit': $result['edit'] = $course->getById($params); break; case 'editChanges': $course->storeFormValues($_POST); $error_msg = $course->update(); break; default: $error_msg = "Operazione non valida"; } if ($error_msg != "") { $result["errorMessage"] = $error_msg; } elseif ($operation != 'edit') { $result["statusMessage"] = "Operazione completata!"; } } if (isset($_POST['search'])) { $result["courses"] = $course->search($_POST['search']); } else { $result["courses"] = $course->getList(); } $page = "course.php"; include_once BASE_PATH . "template.php"; }
function testUpdate() { //Arrange $course_name = "History"; $id = 1; $crn = "HIST101"; $test_course = new Course($course_name, $crn, $id); $test_course->save(); $new_course_name = "Economics"; //Act $test_course->update($new_course_name); //Assert $this->assertEquals("Economics", $test_course->getCourseName()); }
function testUpdate() { $course_name = "History"; $course_code = "HIST100"; $test_course = new Course($course_name, $course_code); $test_course->save(); //Creatin a course with values of History, HIST100, and id from database $new_course_name = "Math"; $new_course_code = "MATH100"; $new_course = new Course($new_course_name, $new_course_code, $test_course->getId()); //creating a new course with values of Math, MATH100, and id that matches test_course $test_course->update($new_course_name, $new_course_code); $this->assertEquals($test_course, $new_course); }
function test_update() { //Arrange $name = "High Times"; $code = "CHEM420"; $test_course = new Course($name, $code); $test_course->save(); //Act $new_name = "Boring Normal Chemistry"; $test_course->update($new_name); //Assert $result = Course::getAll(); $this->assertEquals($new_name, $result[0]->getName()); }
/** * Attempts to update edited course information and displays the edited course. * * @param int $id Id of course to be updated. */ public static function update($id) { $player = self::get_user_logged_in(); if (!$player) { View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat muokata ratoja.')); } $params = $_POST; $params['url'] = self::fix_url($params['url']); $params['mapLink'] = self::fix_url($params['mapLink']); $attributes = array('name' => $params['name'], 'description' => $params['description'], 'address' => $params['address'], 'mapLink' => $params['mapLink'], 'url' => $params['url'], 'id' => $id); $course = new Course($attributes); $errors = $course->errors(); if (count($errors) == 0) { $course->update(); for ($i = 1; $i <= Hole::count_holes($course->id); $i++) { $hole = Hole::find_by_course_and_holenumber($course->id, $i); $hole->name = $params[$i . '_name']; $hole->par = $params[$i . '_par']; $hole->update(); } Redirect::to('/course/' . $course->id, array('message' => 'Radan tietoja muutettu.')); } else { View::make('course/edit.html', array('errors' => $errors, 'attributes' => $attributes)); } }
/** * Display default page * * @return void */ public function testgroundTask() { if (0) { // CREATE COUPON include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCoupon.php'; try { // Constructor take the coupon code $coupon = new Coupon('hui'); // Coupon description (shows up in the cart) $coupon->setDescription('Test coupon, 10% off product with ID 3'); // Expiration date $coupon->setExpiration('Feb 22, 2022'); // Number of times coupon can be used (unlimited by default) $coupon->setUseLimit(1); // Product the coupon will be applied to: // first parameter: product ID // second parameter [optional, unlimited by default]: max quantity of products coupon will be applied to (if buying multiple) $coupon->addObject(3, 1); // Action, only 'discount' for now // second parameter either percentage ('10%') or absolute dollar value ('20') $coupon->setAction('discount', '10%'); // Add coupon $coupon->add(); } catch (\Exception $e) { echo 'ERROR: ' . $e->getMessage(); } return; } if (0) { // DELETE COUPON $warehouse = new Warehouse(); try { $warehouse->deleteCoupon('couponcode3'); } catch (\Exception $e) { echo 'ERROR: ' . $e->getMessage(); } return; } if (0) { // CREATE NEW COURSE include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Course.php'; $course = new Course(); $course->setName('Name of the course'); $course->setDescription('Short description'); $course->setPrice(12.0); $course->addToCollection('courses'); // Membership model: membership duration period (must me in MySQL date format: 1 DAY, 2 MONTH, 3 YEAR...) $course->setTimeToLive('1 YEAR'); // Course alias id $course->setCourseId('nanoscaletransistors'); try { // Returns object with values, pId is the new product ID to link to $info = $course->add(); //print_r($info); } catch (\Exception $e) { echo 'ERROR: ' . $e->getMessage(); } return; } if (0) { // GET EXISTING COURSE, modify it and save $warehouse = new Warehouse(); try { // Get course by pID returned with $course->add() above $course = $warehouse->getCourse(1); $course->setName('Renamed'); $course->setDescription('New description'); $course->setPrice(55.22); $course->setTimeToLive('10 YEAR'); $course->update(); } catch (\Exception $e) { echo 'ERROR: ' . $e->getMessage(); } return; } if (0) { // UPDATE COURSE by recreating it include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCourse.php'; $course = new Course(); $course->setName('Operations Management 104'); $course->setDescription('Operations Management 104 is some kind of test course for now...'); $course->setPrice(13.05); $course->setCourseId(5); // Existing course ID (pID returned with $course->add() when the course was created). Must be set to be able to update. $course->setId(1023); try { $info = $course->update(); //print_r($info); } catch (\Exception $e) { echo 'ERROR: ' . $e->getMessage(); } return; } if (0) { // DELETE COURSE $warehouse = new Warehouse(); // Delete by existing course ID (pID returned with $course->add() when the course was created) $warehouse->deleteProduct(1023); return; } }
if (Imaging::checkDimension($_FILES["image"]["tmp_name"], 400, 400, 'equ', 'both') != 'true') { $uploadOk = 0; $msg = Imaging::checkDimension($_FILES["image"]["tmp_name"], 400, 400, 'equ', 'both'); } if ($uploadOk == 1 && move_uploaded_file($_FILES["image"]["tmp_name"], MEDIA_FILES_PATH . "course-image/" . $courseImageFil)) { $msg .= "The file " . basename($_FILES["image"]["name"]) . " has been uploaded."; $status = 'ok'; if ($oldImage != '' && file_exists(MEDIA_FILES_PATH . "course-image/" . $oldImage)) { unlink(MEDIA_FILES_PATH . "course-image/" . $oldImage); } } else { $uploadOk = 0; } } if ($uploadOk == 1) { echo $courseObj->update(); } else { $msg = " Sorry, there was an error uploading your course media. ERROR: " . $msg; $json = array("status" => 0, "msg" => $msg); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); }
function testUpdate() { $course_name = "Vampires"; $course_number = 1; $id = 1; $test_course = new Course($course_name, $course_number, $id); $test_course->save(); $course_name2 = "Discrete Math"; $course_number2 = 1; $id2 = 2; $test_course2 = new Course($course_name2, $course_number2, $id2); $test_course2->save(); $test_course->update("BOBBIDY BEE BOO"); $result = $test_course->getCourseName(); $this->assertEquals("BOBBIDY BEE BOO", $result); }
function testUpdate() { //Arrange $course_name = "History 110"; $id = 1; $course_number = "HST110"; $test_course = new Course($course_name, $id, $course_number); $test_course->save(); $new_course_name = "Math 101"; //Act $test_course->update($new_course_name); //Assert $this->assertEquals($new_course_name, $test_course->getCourseName()); }