Example #1
0
 /**
  * converts an object to insert/update data
  *
  * @return a comma separated string e.g. "a=1,b=2"
  */
 public function getInsertData($doubleEscaped = false)
 {
     $values = '';
     if ($this->status != null) {
         $this->addInsertData($values, 'CS_status', DBJson::mysql_real_escape_string($this->status));
     }
     if ($this->course != null && $this->course->getId() != null) {
         $this->addInsertData($values, 'C_id', DBJson::mysql_real_escape_string($this->course->getId()));
     }
     if ($values != '') {
         $values = substr($values, 1);
     }
     return $doubleEscaped ? DBJson::mysql_real_escape_string($values) : $values;
 }
Example #2
0
 function test_getId()
 {
     $name = "Math";
     $course_number = "662";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $result = $test_course->getId();
     $this->assertEquals(true, is_numeric($result));
 }
Example #3
0
 /**
  * This static method retrieves all the subjects for a course.
  *
  * @param Course $course
  * @return Criteria
  */
 public static function retrieveForCourseCriteria(Course $course)
 {
     $c = new Criteria();
     $c->add(CourseSubjectPeer::COURSE_ID, $course->getId());
     $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(CareerSubjectPeer::SUBJECT_ID, self::ID, Criteria::INNER_JOIN);
     $c->setDistinct();
     return $c;
 }
 function test_getId()
 {
     //Arrange
     $course_name = "Monster Literature";
     $course_number = "ENG304";
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     //Act
     $result = $test_course->getId();
     //Assert
     $this->assertEquals($id, $result);
 }
 /**
  * Remove a course subscription
  *
  * @param User $user
  * @param Course $course
  * @return boolean
  */
 public function unSubscribe($user, $course)
 {
     try {
         $em = $this->getEntityManager();
         $subscription = $em->getRepository('R4FSiteBundle:Subscription')->findOneBy(array('user' => $user->getId(), 'course' => $course->getId()));
         $em->remove($subscription);
         $em->flush();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
 function testFind()
 {
     $name = "History";
     $course_number = "HIST100";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $name2 = "Math";
     $course_number2 = "MATH100";
     $test_course2 = new Course($name, $course_number);
     $test_course2->save();
     $result = Course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
 function test_find()
 {
     $course_name = "History";
     $course_number = "HIST 101";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     $course_name2 = "Biology";
     $course_number2 = "BIO 101";
     $test_course2 = new Course($course_name2, $course_number2);
     $test_course2->save();
     $result = Course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
 function test_find()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $name = "History 0001";
     $code = "HS001";
     $test_course = new Course($name, $code, $test_department->getId());
     $test_course->save();
     $name2 = "Dogs 101";
     $code2 = "DW101";
     $test_course2 = new Course($name2, $code2, $test_department->getId());
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
 function test_find()
 {
     //Arrange
     $course_name = "MTH101";
     $crn = 1234;
     $id = null;
     $test_course = new Course($course_name, $crn, $id);
     $test_course->save();
     $course_name2 = "HST202";
     $crn2 = 5678;
     $test_course2 = new Course($course_name2, $crn2, $id);
     $test_course2->save();
     //Act
     $id = $test_course->getId();
     $result = Course::find($id);
     //Assert
     $this->assertEquals($test_course, $result);
 }
Example #10
0
 function test_find()
 {
     //Arrange
     $name = "High Times";
     $code = "CHEM420";
     $test_course = new Course($name, $code);
     $test_course->save();
     $name2 = "Gavanese Jamelan";
     $code2 = "MUSC69";
     $test_course2 = new Course($name2, $code2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
 public function saveToDatabase()
 {
     if (isset($this->_infoArr) && isset($this->_mappingArr)) {
         $err = "";
         $conn = Propel::getConnection();
         $dt = date("Y-m-d, H:i:s");
         $len = count($this->_infoArr);
         for ($i = 0; $i < $len; $i++) {
             $course = CoursePeer::retrieveByPK($this->_infoArr[$i]["courseCode"]);
             if (!isset($course)) {
                 // new course found, save to db
                 $course = new Course();
                 $course->setDescr($this->_infoArr[$i]["courseName"]);
                 $course->setIsEng(1);
                 $course->setDeptId(substr($this->_infoArr[$i]["courseCode"], 0, 3));
                 $course->setId($this->_infoArr[$i]["courseCode"]);
                 $course->save($conn);
             } elseif ($course->getDescr() == $course->getId()) {
                 // exam importer registers course description as course id
                 // if we encounter this situation, amend it with the proper description
                 $course->setDescr($this->_infoArr[$i]["courseName"]);
                 $course->save($conn);
             }
             try {
                 $instr = InstructorPeer::findInstructorByName($this->_infoArr[$i]["instrFirstName"], $this->_infoArr[$i]["instrLastName"], $conn);
             } catch (Exception $e) {
                 if ($e->getCode() == 1) {
                     // no instructor found
                     $instr = new Instructor();
                     $instr->setFirstName($this->_infoArr[$i]["instrFirstName"]);
                     $instr->setLastName($this->_infoArr[$i]["instrLastName"]);
                     $instr->setDeptId($course->getDeptId());
                     $instr->save($conn);
                 } else {
                     // TODO: big problem, duplicate instructors found
                     // log error and move on
                     continue;
                 }
             }
             // create CourseInstructorAssociation if it doesn't exist
             try {
                 $assoc = CourseInstructorAssociationPeer::findForYearAndInstructorIdAndCourseId($this->_year, $course->getId(), $instr->getId(), $conn);
             } catch (Exception $e) {
                 if ($e->getCode() == 1) {
                     // create new object
                     $assoc = new CourseInstructorAssociation();
                     $assoc->setYear($this->_year);
                     $assoc->setCourseId($course->getId());
                     $assoc->setInstructorId($instr->getId());
                     $assoc->save($conn);
                 } else {
                     // TODO: big problem, duplicate assocs found
                     // log error and move on
                     continue;
                 }
             }
             // we can now save the real rating data
             $ratingArr = $this->_ratingArr[$i];
             foreach ($ratingArr as $fieldId => $data) {
                 foreach ($data as $rating => $number) {
                     $ratingObj = new AutoCourseRating();
                     $ratingObj->setFieldId($fieldId);
                     $ratingObj->setRating($rating);
                     $ratingObj->setNumber($number);
                     $ratingObj->setImportDt($dt);
                     $ratingObj->setCourseInsId($assoc->getId());
                     $ratingObj->save();
                 }
             }
         }
     } else {
         throw new Exception("readCsv method has not been called.");
     }
 }
Example #12
0
 /**
  * Declares an association between this object and a Course object.
  *
  * @param      Course $v
  * @return     CourseComment The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCourse(Course $v = null)
 {
     if ($v === null) {
         $this->setCourseId(NULL);
     } else {
         $this->setCourseId($v->getId());
     }
     $this->aCourse = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Course object, it will not be re-added.
     if ($v !== null) {
         $v->addCourseComment($this);
     }
     return $this;
 }
 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());
 }
Example #14
0
 function testGetUnits()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $course_title = "Literature";
     $subject = "English";
     $course_description = "Deconstructing English literature.";
     $user_id = $test_user->getId();
     $test_course = new Course($course_title, $subject, $course_description, $user_id);
     $test_course->save();
     $title2 = "Algebra";
     $subject2 = "Math";
     $description2 = "Introduction to algebraic equations.";
     $test_course2 = new Course($title2, $subject2, $description2, $user_id);
     $test_course2->save();
     $unit_title = "Into the Wild";
     $unit_description = "The life and death of Chris McCandless.";
     $course_id = $test_course->getId();
     $test_unit = new Unit($unit_title, $unit_description, $course_id);
     $test_unit->save();
     $result = $test_course->getUnits();
     $this->assertEquals($test_unit, $result[0]);
 }
 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 testDelete()
 {
     //Arrange
     $name = "Math";
     $date = '0000-00-00';
     $id = 1;
     $test_course = new Course($name, $id);
     $test_course->save();
     $student_name = "File reports";
     $id2 = 2;
     $course_id = $test_course->getId();
     $test_student = new Student($student_name, $id2, $date, $course_id);
     $test_student->save();
     //Act
     $test_course->addStudent($test_student);
     $test_course->delete();
     //Assert
     $this->assertEquals([], $test_student->getCourses());
 }
 function testFind()
 {
     //Arrange
     $name = "History";
     $course_number = "HIST101";
     $name2 = "English";
     $course_number2 = "ENG500";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $test_course2 = new Course($name2, $course_number2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
 /**
  * Exclude object from result
  *
  * @param     Course $course Object to remove from the list of results
  *
  * @return    CourseQuery The current query, for fluid interface
  */
 public function prune($course = null)
 {
     if ($course) {
         $this->addUsingAlias(CoursePeer::ID, $course->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 function test_getCourses()
 {
     //Arrange
     $name = "bob";
     $date_of_enrollment = "2015-09-16";
     $test_student = new Student($name, $date_of_enrollment);
     $test_student->save();
     $name2 = "Psychology 101";
     $course_number = "PSY101";
     $test_course = new Course($name2, $course_number);
     $test_course->save();
     $name3 = "Philosophy 101";
     $course_number2 = "PHIL101";
     $test_course2 = new Course($name3, $course_number2);
     $test_course2->save();
     //Act
     $test_student->addCourse($test_course->getId());
     $test_student->addCourse($test_course2->getId());
     //Assert
     $result = $test_student->getCourses();
     $this->assertEquals([$test_course, $test_course2], $result);
 }
 function test_find()
 {
     //Arrange
     $course_name = "History";
     $course_number = "HIST:111";
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     $course_name2 = "Albebra";
     $course_number2 = "MTH:112";
     $id = 2;
     $test_course2 = new Course($course_name2, $course_number2, $id);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
Example #21
0
 function test_find()
 {
     //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_course2 = new Course($title2, $teacher2, $time2, $semester2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
Example #22
0
 function testFind()
 {
     //Arrange
     $name = "Math";
     $course_num = "101";
     $id = 1;
     $test_course = new Course($name, $course_num, $id);
     $test_course->save();
     $name2 = "English";
     $course_num2 = "300";
     $id2 = 2;
     $test_course2 = new Course($name2, $course_num2, $id2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course2->getId());
     //Assert
     $this->assertEquals($test_course2, $result);
 }
 function test_find()
 {
     //Arrange
     $name = "Philosophy";
     $course_number = "PHIL101";
     $name2 = "Pyschology";
     $course_number2 = "PSY101";
     $id = 1;
     $id2 = 2;
     $test_course = new Course($name, $course_number, $id);
     $test_course->save();
     $test_course2 = new Course($name2, $course_number2, $id2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Course $value A Course object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Course $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #25
0
 function testFind()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $course_title = "Literature";
     $subject = "English";
     $course_description = "Deconstructing English literature.";
     $user_id = $test_user->getId();
     $test_course = new Course($course_title, $subject, $course_description, $user_id);
     $test_course->save();
     $unit_title = "Into the Wild";
     $unit_description = "The life and death of Chris McCandless.";
     $course_id = $test_course->getId();
     $test_unit = new Unit($unit_title, $unit_description, $course_id);
     $test_unit->save();
     $lesson_title = "Into the Wild: Chapter 1";
     $objective = "Students will read and discuss Chapter 1";
     $materials = "Books, discussion packets, pencils";
     $body = "Lorem ipsum etc etc blah blah blah blah...";
     $unit_id = $test_unit->getId();
     $test_lesson = new Lesson($lesson_title, $objective, $materials, $body, $unit_id);
     $test_lesson->save();
     $lesson_title2 = "The Catcher in the Rye: Chapter 3";
     $objective2 = "Students will read and discuss Chapter 3";
     $materials2 = "Books, essay prompts, pens";
     $body2 = "Blah blah blah etc etc lorem ipsum...";
     $test_lesson2 = new Lesson($lesson_title2, $objective2, $materials2, $body, $unit_id);
     $test_lesson2->save();
     $result = Lesson::find($test_lesson->getId());
     $this->assertEquals($test_lesson, $result);
 }
Example #26
0
    }
}
// end if (!MULTIPROVIDER)
if (isset($testerName)) {
    $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($testerName));
    // setting of the global is needed to load the course object
    $GLOBALS['dh'] = $tester_dh;
    // load course
    $courseObj = new Course($course_id);
    $courseOK = false;
    if ($courseObj instanceof Course && $courseObj->isFull()) {
        // it it's public, go on and show contents
        $courseOK = $courseObj->getIsPublic();
        if (!$courseOK && isset($_SESSION['sess_userObj']) && $_SESSION['sess_userObj'] instanceof ADALoggableUser) {
            // if it's not public, check if user is subscribed to course
            $instanceCheck = $tester_dh->get_course_instance_for_this_student_and_course_model($_SESSION['sess_userObj']->getId(), $courseObj->getId(), true);
            if (!AMA_DB::isError($instanceCheck) && is_array($instanceCheck) && count($instanceCheck) > 0) {
                $goodStatuses = array(ADA_STATUS_SUBSCRIBED, ADA_STATUS_COMPLETED, ADA_STATUS_TERMINATED);
                $instance = reset($instanceCheck);
                do {
                    $courseOK = in_array($instance['status'], $goodStatuses);
                } while (($instance = next($instanceCheck)) !== false && !$courseOK);
            }
        }
    }
    // courseOK is true either if course is public or the user is subscribed to it
    if ($courseOK) {
        // select nome or empty string (whoever is not null) as title to diplay for the news
        $newscontent = $tester_dh->find_course_nodes_list(array("COALESCE(if(nome='NULL' OR ISNULL(nome ),NULL, nome), '')", "testo"), "tipo IN (" . ADA_LEAF_TYPE . "," . ADA_GROUP_TYPE . ") ORDER BY data_creazione DESC LIMIT " . $count, $course_id);
        // watch out: $newscontent is NOT associative
        $output = '';
 function testFind()
 {
     $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();
     $find_id = $test_course->getId();
     $result = Course::find($find_id);
     $this->assertEquals($test_course, $result);
 }
 public function dettacherImageFromPost(Course $course)
 {
     if (PostWP::hasPostPicture($course->getId())) {
         PostWP::deletePostPicture($course->getId());
     }
 }
 function test_GetAll()
 {
     $name = "Coding 101";
     $enrollment_date = '0000-00-00';
     $id = null;
     $test_course = new Course($name, $id);
     $test_course->save();
     $student_name = "Aladdin";
     $course_id = $test_course->getId();
     $test_student = new Student($student_name, $id, $enrollment_date, $course_id);
     $test_student->save();
     $student_name2 = "Jasmine";
     $id2 = null;
     $course_id2 = $test_course->getId();
     $test_student2 = new Student($student_name2, $id2, $enrollment_date, $course_id2);
     $test_student->save();
     $result = Student::getAll();
     $this->assertEquals(['test_student, $test_student2'], $result);
 }
 function testFind()
 {
     //Arrange
     $name = "Coding 101";
     $id = 1;
     $test_course = new Course($name, $id);
     $test_course->save();
     $name2 = "Advanced Coding";
     $id2 = 2;
     $test_course2 = new Course($name2, $id2);
     $test_course2->save();
     //Act
     $result = Course::find($test_course->getId());
     //Assert
     $this->assertEquals($test_course, $result);
 }