コード例 #1
0
ファイル: add_annotation.php プロジェクト: anzhao/CLAS
/*
if(isUserLoggedIn()) {
    $userID     = $loggedInUser->user_id;
    $userName   = $loggedInUser->display_username;
} else {
    header("Location: $applicationLoginURL");
    exit;
//    print "user NOT logged in";
}
*/
startSession();
$userID = $_SESSION['user_id'];
$userName = $_SESSION['name'];
print_r($_POST);
$annotationIDs = array();
$annotationDB = new annotationsDB();
//$annotations->truncateTable();
//$annotationsCount = $annotations->countAnnotations();
//print "There are $annotationsCount annotation(s) in total.<br /><br />";
$videoID = $_POST['video_id'];
$startTime = $_POST['start_time'];
$endTime = $_POST['end_time'];
$tags = $_POST['tags'];
$description = $_POST['description'];
$isPrivate = $_POST['is_private'];
$isDeleted = "0";
$videoAnnotationID = $_POST['video_annotation_id'];
$confidence_type = $_POST['confidence_level'];
//print "private: $private";
"true" == $isPrivate ? $isPrivate = 1 : ($isPrivate = 0);
/* When adding annotations, the start time and end time needs to be moved back a few seconds 
コード例 #2
0
ファイル: delete_annotation.php プロジェクト: anzhao/CLAS
<?php

require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . "/../includes/kaltura/kaltura_functions.php";
require_once dirname(__FILE__) . "/../database/annotations.php";
startSession();
$userID = $_SESSION['user_id'];
$userName = $_SESSION['name'];
//print "hello";
$annotationIDs = array();
$annotationDB = new annotationsDB();
//$annotations->truncateTable();
//$annotationsCount = $annotations->countAnnotations();
//print "There are $annotationsCount annotation(s) in total.<br /><br />";
$id = $_POST['id'];
$videoAnnotationID = $_POST['video_annotation_id'];
/*
print "POST vars:";
foreach ($_POST as $key=>$val) {
    print "$key:$val\n";
}
print "videoAnnotationID: $videoAnnotationID";
*/
$annotationDB->deleteAnnotation($id, $userID);
$annotationDB->close();
コード例 #3
0
ファイル: clas_adm.php プロジェクト: abelardopardo/oval
function handleCleanAnnotations()
{
    global $classID, $className, $classes, $configFolderName, $dbConnection;
    global $session, $department, $courseNo, $sectionNo, $season;
    global $yteststudent_hashed_id, $iteststu_guest_id, $bteststu_basic_id;
    global $command, $commandState;
    // get the command itself
    $command = Commands::CleanAnnotations;
    // get the state of the command
    if (array_key_exists("execute", $_POST)) {
        $commandState = CommandStates::Execute;
    } else {
        if (array_key_exists("previewThenExecute", $_POST)) {
            $commandState = CommandStates::PreviewThenExecute;
        } else {
            $commandState = CommandStates::Preview;
        }
    }
    printOutputPageHeading($commandState);
    if (!empty($_POST)) {
        // reading and checking params for the command
        if (!(array_key_exists('session', $_POST) && array_key_exists('season', $_POST))) {
            $errors .= "Fatal Error: Session Year or Season is empty. This may be a bug<br/><br/>";
        } else {
            $session = $_POST['session'];
            $season = $_POST['season'];
        }
        populateCourseInfoFromPOST();
        printCourseInfo($commandState, $className, $configFolderName, $session, $department, $courseNo, $sectionNo, $season);
        $media = new media();
        $annotationsDB = new annotationsDB();
        $nothingToDo = false;
        $oldAnnotationsAndComments = array();
        $videosInCourse = $media->getVideosByClassID($classID);
        if (!empty($videosInCourse)) {
            $videosInCourseCount = count($videosInCourse);
            foreach ($videosInCourse as $video) {
                $videosInCourseText[] = "ID:" . $video['video_id'] . " Title:\"" . $video['title'] . "\" Length:" . $video['duration'] . "\n";
                $oldAnnotationCollections[] = $annotationsDB->getAnnotations($video['video_id'], null, true, ALL);
            }
            foreach ($oldAnnotationCollections as $annotationCollection) {
                if (!empty($annotationCollection)) {
                    foreach ($annotationCollection as $annotation) {
                        $oldAnnotationsAndComments[] = $annotation;
                    }
                }
            }
            if ($commandState == CommandStates::Preview) {
                print "<br/><b>There are {$videosInCourseCount} videos in course {$className}.</b><br/>";
                DEBUG_printSimpleArray($videosInCourseText, 8, 70, "\n");
                print "<br/>";
            }
            print "<br/>";
            if (empty($oldAnnotationsAndComments)) {
                print "<b>There is no active annotations and general comments in this course. Nothing to do.</b><br/><br/>";
                $nothingToDo = true;
            } else {
                $oldAnnotationsAndCommentsCount = count($oldAnnotationsAndComments);
                if ($commandState == CommandStates::Preview) {
                    print "<b>There are {$oldAnnotationsAndCommentsCount} annotations and general comments\r\n\t\t\t\t\tfor {$videosInCourseCount} VIDEOs in course {$className}. Please verify before deleting.</b><br/>";
                    print "<div style=\"min-width:1024px;text-align:center;font-size:75%\">";
                    print "<div style=\"margin-left:auto;margin-right:auto;border:1px solid gray;height:200px;width:1030px;white-space:pre-wrap;overflow:scroll;\">";
                    foreach ($oldAnnotationsAndComments as $annotation) {
                        if (!is_null($annotation)) {
                            if ($annotation['is_private'] == 0) {
                                print "Annotation ID " . $annotation['annotation_id'] . " User " . $annotation['user_name'] . " Date " . $annotation['creation_date'] . " Content '" . $annotation['description'] . "' Tags '" . $annotation['tags'];
                            }
                        } else {
                            print "<span style=\"color:red\">null entry. Could be a bug.</span>";
                        }
                        print "<br/>";
                    }
                    print "</div></div>";
                }
            }
        } else {
            print "<b>There is no videos in this course yet. Nothing to do.</b><br/><br/>";
            $nothingToDo = true;
        }
        if (empty($errors)) {
            if (!$nothingToDo) {
                if ($commandState == CommandStates::Execute || $commandState == CommandStates::PreviewThenExecute) {
                    print "<div style=\"min-width:1024px;text-align:center;font-size:75%\">";
                    print "<div style=\"margin-left:auto;margin-right:auto;border:1px solid gray;height:200px;width:1030px;white-space:pre-wrap;overflow:scroll;\">";
                    foreach ($oldAnnotationsAndComments as $annotation) {
                        $annotationID = $annotation['annotation_id'];
                        $result = $annotationsDB->deleteAnnotation($annotationID);
                        UTIL_printQueryResultNicely("delete annotation " . $annotationID, $result, $dbConnection);
                    }
                    if (empty($oldAnnotationsAndComments)) {
                        print "???";
                    }
                    print "</div></div>";
                    print "<br/><b>STOP! Please check the database query outputs to make sure that everything is\r\n\t\t\t\t\t\t\t<span style=\"color:green;\">green</span>\r\n\t\t\t\t\t\t\tbefore finishing.\r\n\t\t\t\t\t\t\t</b><br/>";
                    print "<br/><span style=\"color:blue;font-weight:bold;\">\r\n\t\t\t\t\t\t\tIf you are cleaning annotations for a new term (so that you can reuse the same videos in a course)<br/>\r\n\t\t\t\t\t\t\tYou might also want to update the enrollment list afterward.\r\n\t\t\t\t\t\t\t</span>\r\n\t\t\t\t\t\t\t<br/><br/>";
                    printOutputPageFooting(CommandStates::Execute, $className);
                } else {
                    if ($commandState == CommandStates::Preview) {
                        printExecuteRemoveAnnotationsForm($classID, $session, $season, "Go Ahead and Execute the Annotations Removal");
                        printOutputPageFooting(CommandStates::Preview, $className);
                    }
                }
            } else {
                printOutputPageFooting(CommandStates::Preview, $className);
            }
        } else {
            print "{$errors}";
            printOutputPageFooting(CommandStates::Error, $className);
        }
        $media->close();
        $annotationsDB->close();
    } else {
        print "<br/><span style=\"color:red;font-weight:bold\">\r\n\t\t\t\tFATAL ERROR! POST parameter list empty. You may have found a bug.<br/>\r\n\t\t\t\tPlease email thomas.dang@ubc.ca with as much info as possible of the context when this error appears.<br/>\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/>";
        printOutputPageFooting(CommandStates::Error, $className);
    }
}
コード例 #4
0
ファイル: edit_annotation.php プロジェクト: anzhao/OVAL
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . "/../database/annotations.php";
startSession();
$userID = $_SESSION['user_id'];
$userName = $_SESSION['name'];
//print "hello";
//print_r($_POST);
$annotationIDs = array();
$annotationDB = new annotationsDB();
//$annotations->truncateTable();
//$annotationsCount = $annotations->countAnnotations();
//print "There are $annotationsCount annotation(s) in total.<br /><br />";
$id = $_POST['id'];
$videoID = $_POST['video_id'];
$startTime = $_POST['start_time'];
$endTime = $_POST['end_time'];
$tags = $_POST['tags'];
$isPrivate = $_POST['is_private'];
$description = $_POST['description'];
$videoAnnotationID = $_POST['video_annotation_id'];
"true" == $isPrivate ? $isPrivate = 1 : ($isPrivate = 0);
$msg = $annotationDB->updateAnnotation($id, $videoID, $userID, $userName, $startTime, $endTime, $description, $tags, $isPrivate, 0, $videoAnnotationID);
//print "msg:$msg";
$annotationDB->close();
コード例 #5
0
<?php

require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . "/../database/annotations.php";
startSession();
$userID = $_SESSION['user_id'];
//print "hello";
//print_r($_POST);
$annotationIDs = array();
$annotationDB = new annotationsDB();
//$annotations->truncateTable();
//$annotationsCount = $annotations->countAnnotations();
//print "There are $annotationsCount annotation(s) in total.<br /><br />";
$annotationID = $_POST['annotation_id'];
$annotationDB->updateAnnotationViewCount($annotationID, $userID);
$annotationDB->close();
コード例 #6
0
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . "/../database/annotations.php";
startSession();
$userID = $_SESSION['user_id'];
//print_r($userID);
$videoID = $_GET['video_id'];
//print_r($videoID);
$flagMode = $_GET['flag_mode'];
//print_r($flagMode);
$user = new users();
$annotationsDB = new annotationsDB();
// create file and write to it
$fname = "../downloads/annotations_{$userID}.csv";
$fp = fopen($fname, 'w+');
$user->isInstructorOrTA($userID) ? $isStudent = false : ($isStudent = true);
$annotations = (array) $annotationsDB->getMyAnnotations($videoID, $userID, $flagMode);
$instructorAndTAs = (array) $annotationsDB->getInstructorAndTAAnnotations($videoID, $userID, $flagMode);
$students = (array) $annotationsDB->getStudentAnnotations($videoID, $userID, $flagMode);
if (intval($_GET['viewAll'])) {
    $annotations = array_merge($annotations, $instructorAndTAs, $students);
}
$headings = array('start time', 'name', 'type', 'role', 'tags', 'description');
fputcsv($fp, $headings);
if (count($annotations) > 0) {
    foreach ($annotations as $annotation) {
        $name = $annotation['user_name'];
コード例 #7
0
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
require_once dirname(__FILE__) . "/../includes/common.inc.php";
require_once dirname(__FILE__) . "/../database/annotations.php";
startSession();
$userID = $_SESSION['user_id'];
$videoID = $_GET['video_id'];
$annotationMode = $_GET['annotation_mode'];
$viewMode = intval($_GET['view_mode']);
//(isset($flagMode)) ? $flagMode = true : $flagMode = false;
// strip out hash
$videoID = str_replace("#", "", $videoID);
//print "flagMode($flagMode)\n";
//(is_bool($flagMode)) ? print "flagMode is a bool" : print "flagMode is ! a bool";
//(is_string($flagMode)) ? print "flagMode is a string" : print "flagMode is ! a string";
$annotationsDB = new annotationsDB();
$annotations = $annotationsDB->getAnnotations($videoID, $userID, $annotationMode, $viewMode);
//print_r($annotations);
$jsonString;
// TODO: this bit is redundant
// annotation ownership property
if (count($annotations) > 0) {
    foreach ($annotations as $key => $val) {
        //print "key:$key<br />";
        if ($userID == $annotations[$key]['user_id']) {
            $annotations[$key]['my_annotation'] = "true";
        } else {
            $annotations[$key]['my_annotation'] = "false";
        }
        // automatically make links clickable (while stripping out everything else to prevent XSS)
        $annotations[$key]['description_with_html'] = makeLinksClickable($annotations[$key]['description']);