Beispiel #1
0
<?php

require_once dirname(__FILE__) . '/../includes/common.inc.php';
require_once dirname(__FILE__) . "/../database/media.php";
startSession();
$userID = $_SESSION['user_id'];
$userName = $_SESSION['name'];
//print "hello";
//print_r($_POST);
$videoID = $_POST['video_id'];
$media = new media();
$media->updateTotalViews($userID, $videoID);
$media->close();
Beispiel #2
0
function displayAnalytics()
{
    global $users, $userID, $userName, $videoID, $authorizedUsers, $classes, $classID;
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Video Usage Analytics</title>
<script type="text/javascript" src="kaltura-html5player-widget/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#date-heatmap .day').mouseover(function(event) {
        // the date and number of views (delineated by an underscore) are stored in the class tag
        var classTag  = $(this).attr('class');
        underscorePos = classTag.indexOf("_");
        viewDate      = classTag.substring(0, underscorePos);
        viewCount     = classTag.substring(underscorePos+1, classTag.indexOf(" "));
        if ("" == viewCount) viewCount = 0;

        $('<div id="date" style="border:1px solid gray;background-color:#fff;padding:2px 4px 2px 4px;width:auto;z-index:100;">' + viewDate + ' (' + viewCount + ' views)<br style="margin-bottom:10px;"/></div>').appendTo('body');

        showDate(event);
    });

    function showDate(event) {
        var tPosX = event.pageX + 15 + 'px';
        var tPosY = event.pageY + 15 + 'px';
        $('#date').css({'position': 'absolute', 'top': tPosY, 'left': tPosX});
    }

    $('#date-heatmap .day').mouseout(function(event) {
        $('#date').remove();
    });

});
</script>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="stylesheet" type="text/css" href="admin-page.css" />
</head>
<body>
<?php 
    printAdminBar(false, $userName);
    ?>
    <div style="clear:both"></div>
    <strong>Video Usage Analytics</strong>
    <br />
    <br /> 
    <label align="left">select course <select name="class" id="class" onchange="jumpBoxClass()">
<?php 
    //print "classID: $classID";
    foreach ($classes as $class) {
        //print_r($class);
        $ID = $class['ID'];
        $name = $class['name'];
        $classID == $ID ? $selected = "selected=\"selected\"" : ($selected = "");
        print "\t<option value=\"{$ID}\" {$selected}>{$name}</option>\n";
    }
    ?>
    </select>
    </label>


<label style="font-size:100%">select video
    <select>
    <option>All</option>


  
    <?php 
    mysql_connect('localhost', 'root', 'Adelaide160');
    mysql_select_db('prod_annotation_tool');
    // $query="select title from media where video_id IN (SELECT video_id FROM videoGroup)";
    // $query="SELECT m.title FROM videoGroup v, media m WHERE v.group_id=$groupID AND m.video_id LIKE v.video_id ORDER BY m.title";
    $media = new media();
    print_r($groupIDs);
    //for ($i=0; $i<count($groupIDs); $i++):
    //$videoIDs = array_keys($media->getVideosByGroupID($userID,$groupIDs[$i]));
    //print_r($videoIDs);print "<br />";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        echo "<option>";
        echo $row['title'];
        echo "</option>";
    }
    ?>
</select>
   

    </select>
    </label>


    <form id="form1" name="form1" method="post" action="" >
        <table style="width:800px;height:auto;">
            <thead>
                <tr style="border-bottom:1px solid black">
                    <th>Video(s)</th>
                    <th>Unique Users</th>
                    <th>% of class</th>
                    <th>Total of Annotations</th>
                    <th>Total of Summaries</th>
                </tr>                
            </thead>
            <tbody>
<?php 
    $groupIDs = array_keys($users->getGroupsByClassID($classID));
    //print_r($groupIDs);print "<br />";
    $userInfo = null;
    $media = new media();
    for ($i = 0; $i < count($groupIDs); $i++) {
        // fetch videos for given group
        $videoIDs = array_keys($media->getVideosByGroupID($userID, $groupIDs[$i]));
        //print_r($videoIDs);print "<br />";
        for ($j = 0; $j < count($videoIDs); $j++) {
            $groupMembers = $users->getGroupMembers($groupIDs[$i]);
            // TODO: cache this info
            $userInfo = $users->getUserInfo($groupMembers);
            //print_r($groupMembers);print "<br />";
            //print "userInfo: "; print_r($userInfo);print "<br />";
            $thumbnail = $media->getProperty($videoIDs[$j], 'thumbnail_url');
            $title = $media->getProperty($videoIDs[$j], 'title');
            ?>
            <div style="width:900px;"></div>
<?php 
            for ($k = 0; $k < count($groupMembers); $k++) {
                //array_push($viewerStats, $media->getViewerStatistics($userInfo[$k]['User_ID'], $videoIDs[$j]));
                //$viewerStats[$k] = $media->getViewerStatistics($userInfo[$k]['User_ID'], $videoIDs[$j]);
                $playStatus[$k] = $media->getPlayStatistics($videoIDs[$j]);
                //print_r($viewerStats[$k]);
            }
            // find first timestamp and last time stamp
            $dates = getDateRange($viewerStats);
            // calculate range and convert it to days
            $range = intval((strtotime($dates['last_view']) - strtotime($dates['first_view'])) / (60 * 60 * 24)) + 1;
            $maxDailyViews;
            $dailyViews = getDailyViews($viewerStats, $maxDailyViews);
            for ($k = 0; $k < count($groupMembers); $k++) {
                //print "\$groupMembers[$k]: "; print_r($groupMembers);
                //print_r($viewerStats); print "<br />";
                ?>
            <tr style="border-bottom:1px solid black">
<?php 
                if (0 == $k) {
                    print "<td style=\"border-right:1px solid black;background-color:#eee;\" rowspan=\"" . count($groupMembers) . "\"><img src=\"{$thumbnail}\" alt=\"video thumbnail\" /><br />{$title}<br /></td>";
                    echo "<td>";
                    echo $media->getUniqueUsers($videoIDs[$j]);
                    echo "</td>";
                    echo "<td>";
                    echo round($media->getUniqueUsers($videoIDs[$j]) / $media->getNumAnnotations($videoIDs[$j]) * 100 / 2, 2);
                    echo "</td>";
                    echo "<td>" . $media->getNumAnnotations($videoIDs[$j]) . "</td>";
                    echo "<td>" . $media->getNumSummaries($videoIDs[$j]) . "</td>";
                }
                ?>
               
<?php 
            }
        }
    }
    $media->close();
    ?>
    

            </tr>

    
                               
        <br />  
        </tbody>
        </table>
    </form>
</body>
</html>
<?php 
}
Beispiel #3
0
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);
    }
}
Beispiel #4
0
 function trendlineVisible($userID, $videoID)
 {
     // print "trendlineVisible($userID, $videoID)<br />";
     $allowAccess = false;
     // $users = new users();
     $uiConfig = $this->getUI($userID);
     // $users->close();
     // print_r($uiConfig);
     $trendlineVisibility = $uiConfig['trendline_visibility'];
     $n = $uiConfig['n'];
     $media = new media();
     $stats = $media->getViewerStatistics($userID, $videoID);
     $media->close();
     switch ($trendlineVisibility) {
         case BY_DEFAULT:
             $allowAccess = true;
             break;
         case AFTER_N_DAYS:
             // check timestamp
             $firstViewTime = strtotime($stats['first_view']);
             $currentTime = time();
             $nDays = $n * (60 * 60 * 24);
             if ($currentTime <= $firstViewTime + $nDays) {
                 $allowAccess = true;
             }
             sendEmail("stats: {$stats['first_view']}\nif ({$currentTime} <= {$firstViewTime} + {$nDays})", "trendlineVis");
             break;
         case AFTER_N_VIEWS:
             // check number of views
             if ($stats['total_views'] >= $n) {
                 $allowAccess = true;
             }
             sendEmail("({$stats['total_views']} >= {$n})", "trendlineVis");
             break;
     }
     return $allowAccess;
 }