Exemplo n.º 1
0
 public function getCourse($deptAbbr, $num)
 {
     if (strpos($num, '/') !== false) {
         $split = split('/', $num);
         $courseNum = $split[0];
     } else {
         $courseNum = $num;
     }
     for ($i = 0; $i < 3; $i++) {
         $courseString = $deptAbbr . str_repeat('%20', $i) . str_pad($courseNum, 4, '0', STR_PAD_LEFT);
         $baseUrl = 'https://webcenter.studentservices.tufts.edu/coursedesc/?courseid=';
         $result = htmlspecialchars_decode(curl_get($baseUrl . $courseString));
         if (preg_match("/4\"\\>\\<B\\>(.+?)\\s{2,}/", $result, $matches)) {
             break;
         }
     }
     if ($matches) {
         return array('Num' => $num, 'Name' => formatCourseName(trim($matches[1])));
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
    $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($m[2])->findOne();
    if ($dept) {
        $dept->setName($m[3])->save();
    }
    $url = "https://banner-as1.admin.wpi.edu" . $m[1];
    $result = curl_get($url);
    /*
        <TD><A HREF="http://www.wpi.edu/Pubs/Catalogs/Ugrad/Current/ascourses.html#as1001">AS 1001</A> A01</TD> 
    <TD>FOUNDATIONS OF US AIR FORCE I</TD> 
    <TD>    1/9</TD> 
    <TD>Lec</TD> 
    <TD>--W--</TD> 
    <TD>2:00-2:50</TD> 
    <TD>HL202</TD> 
    <TD><A HREF="http://www.wpi.edu/Pubs/Faculty/brk.html">Kaanta, Bryan R.</A></TD>
    * 
    */
    preg_match_all("/#.+?\"\\>([A-Z]+)\\s(\\d+)\\<\\/A\\>(.+?)\\<\\/TD\\>\n\\<TD\\>(.+?)\\<\\/TD\\>\n.+\n.+\n.+\n.+\n.+\n\\<TD\\>(.*)\\<\\/TD/", $result, $matches2, PREG_SET_ORDER);
    print_r($matches2);
    foreach ($matches2 as $n) {
        $section = SectionQuery::create()->filterBySchool($school)->filterByNum($n[3])->useCourseQuery()->filterByNum($n[2])->useDeptQuery()->filterByAbbr($n[1])->endUse()->endUse()->findOne();
        if ($section) {
            $section->setName(formatCourseName($n[4]));
            if (preg_match("/\\>(.+),/", $n[5], $mat)) {
                $section->setProfessor($mat[1]);
            }
            $section->save();
        }
    }
}
//"<A HREF="/pls/prod/hwwkrnbw.P_DisplayDept?sel_term=201101&sel_ptrm=A&sel_dept=AS&sel_desc=Aerospace+Studies++(AFROTC)&sel_level=01&sel_campus=x">Aerospace Studies  (AFROTC)</A>
Exemplo n.º 3
0
        //var_dump($result);
        //die();
        preg_match_all("/header\"\\>(.+?)\\</", $result, $matches);
        $matches = $matches[1];
        print_r($matches);
        for ($i = 0; $i < count($matches); $i += 11) {
            $num = substr($matches[$i], strpos($matches[$i], '0'), 6);
            $section = curl_get("http://voyager.adminsvc.temple.edu/tucourses/tu_coursesdescrip.asp?name={$num}&Clear=Yes");
            if (preg_match("/Instructor.+?descripNobold\"\\>([^<]+?),([^<]+?)\\</s", $section, $m)) {
                $prof = trim(preg_replace("/\\s+/", ' ', $m[2] . $m[1]));
            } else {
                $prof = null;
            }
            $cnum = ltrim($matches[$i + 1], '0');
            $snum = $matches[$i + 3];
            $cname = formatCourseName($matches[$i + 4]);
            $course = CourseQuery::create()->filterByDept($dept)->filterByNum($cnum)->findOne();
            if ($course) {
                echo "setting {$cname}\n";
                $course->setName($cname)->save();
                if ($prof) {
                    $section = SectionQuery::create()->filterByCourse($course)->filterByNum($snum)->findOne();
                    if ($section) {
                        echo $prof . "\n";
                        $section->setProfessor($prof)->save();
                    }
                }
            }
        }
    }
}
Exemplo n.º 4
0
$depts = DeptQuery::create()->filterBySchool($school)->find();
foreach ($depts as $d) {
    if (isset($departments[$d->getAbbr()])) {
        $d->setName($departments[$d->getAbbr()])->save();
    }
}
// update courses
$term = "Spring+2011";
$url1 = "http://fusionmx.babson.edu/CourseListing/index.cfm?fuseaction=CourseListing.DisplayCourseListing&blnShowHeader=false&program=Graduate&semester={$term}&sort_by=course_number&btnSubmit=Display+Courses";
$url2 = "http://fusionmx.babson.edu/CourseListing/index.cfm?fuseaction=CourseListing.DisplayCourseListing&blnShowHeader=false&program=Undergraduate&semester={$term}&sort_by=course_number&btnSubmit=Display+Courses";
$result = curl_get($url2) . curl_get($url1);
preg_match_all("/85\"\\>([A-Z]+)(\\d+)\\-([A-Z\\d]+)\\<\\/td\\>.+?400\\);\"\\>(.+?)\\<\\/a.+?nowrap\"\\>(.+?),.+?\\<\\/span/s", $result, $matches, PREG_SET_ORDER);
foreach ($matches as $m) {
    unset($m[0]);
    print_r($m);
    $dept = DeptQuery::create()->filterBySchool($school)->filterByAbbr($m[1])->findOne();
    if (!$dept) {
        continue;
    }
    $course = CourseQuery::create()->filterByDept($dept)->filterByNum(ltrim($m[2], '0'))->findOne();
    if (!$course) {
        continue;
    }
    $name = preg_replace("/\\(.+\\)\$/", "", $m[4]);
    $course->setName(formatCourseName($name))->save();
    $section = SectionQuery::create()->filterByCourse($course)->filterByNum($m[3])->findOne();
    if (!$section) {
        continue;
    }
    $section->setProfessor(trim($m[5]))->save();
}