예제 #1
0
$client_id = 'YXA6wDs-MARqEeSO0VcBzaqg5A';
$client_secret = 'YXA6JOMWlLap_YbI_ucz77j-4-mI0JA';
$base_url = "https://a1.easemob.com/YOUR_ORG_NAME/YOUR_APP_NAME/";
$i = 10;
switch ($i) {
    case 10:
        //获取token
        var_dump(getToken());
        break;
    case 11:
        //创建单个用户
        var_dump(createUser("zhangsan", "123456"));
        break;
    case 12:
        //创建批量用户
        var_dump(createUsers(array(array("username" => "zhangsan", "password" => "123456"), array("username" => "lisi", "password" => "123456"))));
        break;
    case 13:
        //重置用户密码
        var_dump(resetPassword("zhangsan", "123456"));
        break;
    case 14:
        //获取单个用户
        var_dump(getUser("zhangsan"));
        break;
    case 15:
        //获取批量用户---不分页(默认返回10个)
        var_dump(getUsers());
        break;
    case 16:
        //获取批量用户----分页
예제 #2
0
function updateClassEnrollment($classID, $dbConn, $command, $commandState, $csvStudentListArray = null)
{
    global $session, $department, $courseNo, $sectionNo, $season, $yteststudent_hashed_id;
    $isCourseNo4Character = strlen($courseNo) == 4;
    $oldEnrolled = getStudentsInClass_FROM_OVAL_DB($classID, $dbConn);
    $oldEnrolled = empty($oldEnrolled) ? array() : $oldEnrolled;
    $oldEnrolledTotal = count($oldEnrolled);
    if ($command == Commands::ImportFromSIS) {
        if (is_null($department) || strlen($department) < 4 || (is_null($courseNo) || strlen($courseNo) < 3 || strlen($courseNo) > 4 || !is_numeric(substr($courseNo, 0, strlen($courseNo - 1)))) || (is_null($sectionNo) || strlen($sectionNo) < 3 || strlen($sectionNo) > 4)) {
            print "<br/><span style=\"color:red;font-weight:bold\">\r\n\t\t\t\t\tSTOP! This OVAL course does not appear to be a standard UBC course!\r\n\t\t\t\t\t<br/>\r\n\t\t\t\t\tThe enrollment list cannot be queried automatically from SIS.\r\n\t\t\t\t\t<br/>\r\n\t\t\t\t\tPlease return to the main menu and import a CSV student list instead.\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t<br/>";
            return;
        }
    }
    if (empty($csvStudentListArray)) {
        $studentNos = getStudentNumbers_FROM_SIS($session, $department, $courseNo, $sectionNo, $season);
    } else {
        $studentNos = $csvStudentListArray;
        $totalEnrolled = $studentNos == null ? 0 : count($studentNos);
        print "<br/>New enrollment list (excluding the test account): {$totalEnrolled} students<br/>";
        if ($commandState != CommandStates::Execute) {
            DEBUG_printSimpleArray($studentNos);
            print "<br/>";
        }
        print "<br/>";
    }
    // Courses with letters at the end sometimes have problems, let's try again!
    if ($isCourseNo4Character && $command == Commands::ImportFromSIS) {
        $courseNoWoutLetter = substr($courseNo, 0, 3);
        if (empty($studentNos)) {
            print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: Has zero students. Let's try again once.</span>\r\n\t\t\t\t\t<br/><br/>";
            $studentNos = getStudentNumbers_FROM_SIS($session, $department, $courseNoWoutLetter, $sectionNo, $season);
        }
    }
    if (!empty($studentNos)) {
        $EntriesToSkip = array();
        foreach ($studentNos as $key => $studentNo) {
            if (!is_null($studentNo) && strlen($studentNo) >= 2) {
                $newEnrolled[] = hashUserID($studentNo);
            } else {
                $EntriesToSkip[] = $key + 1;
            }
        }
        if (!empty($EntriesToSkip)) {
            print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: Several input ID's were found to be corrupted (blank, too short, etc.) and skipped, at positions:<br/>\r\n\t\t\t\t\t</span>";
            DEBUG_printSimpleArray($EntriesToSkip, 1, 70);
            print "<br/><br/>";
        }
        // yteststudent account
        $newEnrolled[] = $yteststudent_hashed_id;
        print "Also include the test student account, hashed student ID: {$yteststudent_hashed_id}<br/>";
        $newEnrolledTotal = count($newEnrolled);
        $compareViewWidth = $commandState == CommandStates::Preview ? "1000px" : "800px";
        $compareViewMinWidth = $compareViewWidth - 10;
        print "<div style=\"min-width:{$compareViewMinWidth}" . "px;text-align:center;\">";
        print "<br/><fieldset style=\"border:0px;margin:0px;padding:0px;margin-left:auto;margin-right:auto;width:{$compareViewWidth}\">";
        print "<div style=\"float:left;\">Existing enrollment list in OVAL (hashed): <b>{$oldEnrolledTotal} students</b><br />";
        if ($commandState == CommandStates::Preview) {
            DEBUG_printSimpleArray($oldEnrolled);
        }
        print "</div>";
        print "<div style=\"float:right\">New enrollment list (hashed): <b>{$newEnrolledTotal} students</b><br />";
        if ($commandState == CommandStates::Preview) {
            DEBUG_printSimpleArray($newEnrolled);
        }
        print "</div>";
        print "</fieldset>";
        print "</div>";
        // get the difference
        $usersToAdd = array_diff($newEnrolled, $oldEnrolled);
        $usersToDrop = array_diff($oldEnrolled, $newEnrolled);
        $usersToAddTotal = count($usersToAdd);
        $usersToDropTotal = count($usersToDrop);
        print "<div style=\"min-width:{$compareViewMinWidth}" . "px;text-align:center;\">";
        print "<br/><fieldset style=\"border:0px;margin:0px;padding:0px;margin-left:auto;margin-right:auto;width:{$compareViewWidth}\">";
        print "<div style=\"float:left\">Users to add to {$session}{$season} {$department} {$courseNo} {$sectionNo}: <b>{$usersToAddTotal} students</b><br />";
        if ($commandState == CommandStates::Preview) {
            DEBUG_printSimpleArray($usersToAdd);
        }
        print "</div>";
        print "<div style=\"float:right\">Users to drop from {$session}{$season} {$department} {$courseNo} {$sectionNo}: <b>{$usersToDropTotal} students</b><br />";
        if ($commandState == CommandStates::Preview) {
            DEBUG_printSimpleArray($usersToDrop);
        }
        print "</div>";
        print "</fieldset>";
        print "</div>";
        print "<br/>";
        $nothingToDo = $usersToAddTotal == 0 && $usersToDropTotal == 0;
        if ($nothingToDo) {
            print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: apparently both the \"to add\" and \"to drop\" lists are empty.<br/>\r\n\t\t\t\t\tThere is probably nothing to do for this command, or you should import another data source.\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t<br/><br/>";
        }
        if ($isCourseNo4Character && $command == Commands::ImportFromSIS) {
            print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: SIS often doesn't return correct enrollment lists for courses ending with a letter.<br/>\r\n\t\t\t\t\tIf the number of students is different from students.ubc.ca, please import an enrollment list (csv) manually.</span>\r\n\t\t\t\t\t<br/><br/>";
        }
        if ($nothingToDo) {
            return;
        }
        if ($commandState == CommandStates::Preview) {
            print "<span style=\"color:red;font-weight:bold\">\r\n\t\t\t\tSTOP! Check the student numbers, or at least the total number enrolled, against students.ubc.ca to make sure!\r\n\t\t\t\t<br>\r\n\t\t\t\tPlease also double check the year, season, etc. to ensure that you are updating the course that you intended!\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/><br/>";
            printExecuteImportCSVForm($classID, $session, $department, $courseNo, $sectionNo, $season, "Go Ahead and Execute the Update(s)", $studentNos);
        } else {
            print "<span style=\"font-weight:bold\">\r\n\t\t\t\tSTOP! Please check the results of the database updates to OVAL \r\n\t\t\t\t<br>\r\n\t\t\t\tto make sure that all the results are <span style=\"color:green\">green</span>\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/><br/>";
            // The rest of the debug messages (SQL output) goes into a text area, for neatness
            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;\">";
            // add new users to the course, creating new users if necessary.
            $userIDs = createUsers($usersToAdd, STUDENT, $dbConn, true);
            addStudents($classID, $userIDs, $dbConn);
            UTIL_setDefaultUISettings($userIDs);
            UTIL_addToEveryoneGroup($userIDs, $classID, $dbConn);
            // dropping old students from the course and the everyone_group
            UTIL_dropHashedStudentsFromCourse($usersToDrop, $classID, $dbConn);
            print "</div></div>";
        }
    } else {
        print "<span style=\"color:red;font-weight:bold\">\r\n\t\t\t\tSTOP! SIS returns 0 students in the course for this term. Perhaps try again later or import a spreadsheet.\r\n\t\t\t\t<br>\r\n\t\t\t\tAlso double check the year, season, etc. to ensure that you are updating the course that you intended!\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/>";
    }
}
예제 #3
0
파일: schema.php 프로젝트: cmsx/auth
 protected function createAll()
 {
     createUsers();
     createSessions();
 }