예제 #1
0
파일: index.php 프로젝트: ritthai/LMS
             header("Content-Type: text/html");
             header("Connection:");
             header("Content-length:");
             echo "Could not vote.";
         } else {
             header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
             header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
             header("Cache-Control: no-cache, must-revalidate");
             header("Pragma: no-cache");
             header("Content-Type: text/html");
             header("Connection:");
             header("Content-length:");
             echo "Vote successful.";
             Error::generate('debug', 'memcached delete ' . $params['cid']);
             $p = (int) $params['id'];
             $crs = new CourseDefn($p);
             $success = $crs->load();
             $memcached->delete($crs->cid);
         }
     }
 } else {
     if ($action == 'post') {
         // post a comment
         if (!$params['owner'] || !User::IsAuthenticated()) {
             //check_perms(false);
             Error::generate('warn', 'Must be logged in to post a comment.', Error::$FLAGS['single']);
             die('Must be logged in to post a comment.');
         } else {
             if (!($cid = Comment::Create(array('subject' => xssfilterstring($params['subject']), 'body' => xssfilterstring($params['body']), 'owner' => User::GetAuthenticatedID(), 'id' => xssfilterint($params['cid']))))) {
                 Error::generate('warn', 'Could not create comment.', Error::$FLAGS['single']);
             }
예제 #2
0
파일: index.php 프로젝트: ritthai/LMS
$first_load = false;
$search_results = array();
$gcourse_code = "";
$gtitle = "";
$gtags = "";
$gdescr = "";
/*foreach($ACTIONS as $key => $val)
	if($val->wasCalled())
		$action = $key;*/
/**	
	Identify course, populate fields
*/
if ($ACTIONS['search']->wasCalled()) {
    $params = $ACTIONS['search']->getParams();
    $gcourse_code = $gtitle = $params[0];
    $crs = new CourseDefn($gtitle);
    if (!$crs->load()) {
        Error::generate(Error::$PRIORITY['warn'], 'Course not found.');
    }
    $gdescr = $crs->descr;
    $tags = split('[,]', $gtags);
    $procd_descr = process_description($gdescr);
    foreach ($procd_descr as $descr) {
        array_push($search_results, array('subject' => $descr, 'google' => google_search($descr), 'youtube' => youtube_search($descr, $tags), 'itunesu' => itunesu_search($descr), 'khanacad' => khanacad_search($descr)));
    }
}
/* else if(isset($_POST['save_name'])) {
	$crs = new Course(	urlencode($_POST['save_name']), urlencode($_POST['course_prof']),
						$_SESSION['google'], $_SESSION['youtube']);
	$crs->save();
} else if(isset($_GET['course'])) {
예제 #3
0
파일: mysql_init.php 프로젝트: ritthai/LMS
$uni_id = University::GetID('University of Waterloo');
profiling_start('create courses');
foreach ($xml as $a) {
    if ($a['tag'] == "CODE") {
        $code = $a['value'];
    } else {
        if ($a['tag'] == "TITLE") {
            $title = $a['value'];
        } else {
            if ($a['tag'] == "DESCRIPTION") {
                $descr = $a['value'];
                $code = ltrim(rtrim($code));
                $title = ltrim(rtrim($title));
                $descr = ltrim(rtrim($descr));
                $cid = Comment::Create(array('subject' => $code, 'id' => 1));
                $cd = new CourseDefn(mysql_real_escape_string(htmlspecialchars($code)));
                $cd->title = db_real_escape_string(htmlspecialchars($title));
                $cd->descr = db_real_escape_string(htmlspecialchars($descr));
                $cd->cid = $cid;
                $cd->university = $uni_id;
                $cd->save();
                /*		// This code is SLOW (increases runtime by 10x):
                		$procd_descr = process_description($cd->descr);
                		foreach($procd_descr as $k => $topic) {
                			// add to sparse matrix for similarity computation
                			// prefetch relevant links with low priority
                		}
                */
            }
        }
    }
예제 #4
0
파일: gatherer.php 프로젝트: ritthai/LMS
<?php

@(include "{$ROOT}/includes/tags.inc");
@(include "dataacquisition/google.util.php");
@(include "dataacquisition/youtube.util.php");
@(include "dataacquisition/itunesu.util.php");
@(include "dataacquisition/khanacad.util.php");
@(include "{$ROOT}/includes/subjects.inc");
@(include "{$ROOT}/includes/universities.inc");
@(include "{$ROOT}/includes/geography.inc");
db_connect();
Error::showSeparator();
Error::generate('debug', 'Starting preload process');
Error::showSeparator();
foreach (CourseDefn::ListAll() as $crs) {
    Error::showSeparator();
    Error::generate('debug', 'Preloading ' . $crs->university . ': ' . $crs->code);
    // TODO: preload
    Error::showSeparator();
}
Error::showSeparator();
Error::generate('debug', 'Ending preload process');
Error::showSeparator();
예제 #5
0
<?php 
}
?>
                            <div id="sidebar_course_similarities">Similar courses:</div>
								<div id="sidebar_similarities_tagcloud_hidden" class="hidden">
<?php 
$ctr = 0;
Error::setPrepend($similarities);
Error::generate('debug', 'Similarity array');
$topn = 10;
// limit to $topn top results
foreach ($similarities as $k => $v) {
    if (++$ctr == $topn) {
        break;
    }
    // limit to $topn top results
    $id = intval($k);
    $subj = ucfirst(Comment::GetSubject($id));
    $crs = new CourseDefn($subj);
    $crs->load();
    $hrefid = $crs->id;
    // cloudinizr javascript is in template_end
    for ($i = 0; $i < (double) $similarities[$k] * 10; $i++) {
        echo strtoupper("{$subj} ");
    }
}
?>
							</div>
							<div id="sidebar_similarities_tagcloud">&nbsp;</div>
						</div>