Exemple #1
0
function handleCreateCourse()
{
    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;
    global $Jenny_hashed_id, $Thomas_hashed_id;
    // get the command itself
    $command = Commands::CreateCourse;
    // get the state of the command
    $commandState = CommandStates::Execute;
    printOutputPageHeading($commandState);
    if (!empty($_POST)) {
        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'];
        }
        $is_SIS_course = $_POST['is_SIS_course'];
        if ($is_SIS_course == "yes") {
            $department = $_POST['department'];
            $courseNo = $_POST['course_number'];
            $sectionNo = $_POST['section_number'];
            $department = strtoupper($department);
        } else {
            $className = $_POST['course_name'];
            if (is_null($className) || strlen($className) == 0) {
                $errors .= "Error: You must enter a class name<br/>";
            }
        }
        $instructorIDs = $_POST['instructor_id'];
        $taIDs = $_POST['TA_ids'];
        // validate inputs
        if (!empty($instructorIDs)) {
            $instructorIDs = UTIL_textArea2Array($instructorIDs);
        } else {
            $errors .= "Fatal Error: Instructor List is Empty!<br/><br/>";
        }
        if (!empty($taIDs)) {
            $taIDs = UTIL_textArea2Array($taIDs);
        }
        // Extra admin hash ids, TODO: factor into an array for neatness
        $extraAdminHashIDs = array();
        $extraAdminHashIDs[] = $Jenny_hashed_id;
        $extraAdminHashIDs[] = $Thomas_hashed_id;
        // Extra student hash ids
        $extraStudentHashIDs = array();
        $extraStudentHashIDs[] = $yteststudent_hashed_id;
        if ($is_SIS_course == "yes") {
            if (is_null($courseNo) || strlen($courseNo) == 0) {
                $errors .= "Error: you must enter a course number<br/>";
            } else {
                if (is_numeric(substr($courseNo, 0, 3))) {
                    if (strlen($courseNo) == 4) {
                        if (!is_alpha(substr($courseNo, 3, 1))) {
                            $errors .= "Error: course number must be three digits plus an optional letter, ex. '300' or '300B'<br/><br/>";
                        }
                    }
                } else {
                    $errors .= "Error: course number must be three digits plus an optional letter, ex. '301' or '301A'<br/><br/>";
                }
            }
            if (is_null($sectionNo) || strlen($sectionNo) == 0) {
                $errors .= "Error: you must enter a section number<br/>";
            } else {
                // pad section number to three digits
                while (strlen($sectionNo) < 3) {
                    $sectionNo = "0" . $sectionNo;
                }
            }
            // Assemble the name
            $className = getCourseName($department, $courseNo, $sectionNo);
            $className = $className . "_{$session}{$season}";
            if (in_array($className, $classes)) {
                $errors .= "Error: {$className} already exists<br/><br/>";
            }
        } else {
            $className = $className . "_{$session}{$season}";
            if (in_array($className, $classes)) {
                $errors .= "Error: {$className} already exists<br/><br/>";
            }
        }
        if (empty($errors)) {
            print "<b>Course Name to be Created: {$className}</b><br/><br/>";
            print "<b>Instructors List:</b><br/>";
            DEBUG_printSimpleArray($instructorIDs, 1);
            print "<br/><br/>";
            print "<b>TA's List:</b><br/>";
            DEBUG_printSimpleArray($taIDs, 1);
            print "<br/><br/>";
            print "<b>Creating Instructor Account(s) if Not Yet Existed</b><br/>";
            if (!empty($instructorIDs)) {
                // 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;\">";
                $instructorIDs = createUsers($instructorIDs, INSTRUCTOR, $dbConnection);
                print "</div></div><br/>";
            } else {
                print "Nothing To Do...<br/><br/>";
            }
            print "<b>";
            if (!empty($taIDs)) {
                print "Creating Teaching Assistant Account(s) if Not Yet Existed<br/>";
            } else {
                print "There are no TA's in the Course (for now)<br/><br/>";
            }
            print "</b>";
            if (!empty($taIDs)) {
                // 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;\">";
                $taIDs = createUsers($taIDs, TA, $dbConnection);
                print "</div></div><br/>";
            }
            print "<b>";
            if (!empty($extraAdminHashIDs)) {
                print "Creating Extra Administrator Account(s) - Arts Helpdesk, LC, etc.<br/>";
            } else {
                print "There are no extra admin accounts in the course for now.<br/><br/>";
            }
            print "</b>";
            $extraAdminIDs = null;
            if (!empty($extraAdminHashIDs)) {
                // 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;\">";
                $extraAdminIDs = createUsers($extraAdminHashIDs, INSTRUCTOR, $dbConnection, true);
                print "</div></div><br/>";
            }
            print "<b>";
            if (!empty($extraStudentHashIDs)) {
                print "Creating Extra Student Account(s) for Testing (yteststudent, iteststu, bteststu)<br/>";
            } else {
                print "There are no extra student accounts in the course for now.<br/><br/>";
            }
            print "</b>";
            $extraStudentIDs = null;
            if (!empty($extraStudentHashIDs)) {
                // 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;\">";
                $extraStudentIDs = createUsers($extraStudentHashIDs, STUDENT, $dbConnection, true);
                print "</div></div><br/>";
            }
            // initial student list
            $studentIDs = $extraStudentIDs;
            // create and populate class
            $classID = createClass($className, $dbConnection);
            // merge admin lists
            $instructorIDs = array_merge($instructorIDs, $extraAdminIDs);
            addInstructorAndTAs($classID, $instructorIDs, $taIDs, $dbConnection);
            // create default groups
            $users = new users();
            print "<b>Create Default Group {$className}" . "_everyone</b><br/><br/>";
            $groupName = $className . "_everyone";
            // This can deal with a null userID list, only instructorID and classID is utterly necessary
            $users->createGroup($groupName, $studentIDs, $instructorIDs, $classID);
            // Instructors and TA
            print "<b>Create Default Group {$className}" . "_instructorAndTA</b><br/><br/>";
            $groupName = $className . "_instructorAndTA";
            $users->createGroup($groupName, null, $instructorIDs, $classID);
            // set default UI for each user, first, let's merge all the arrays created so far.
            if (empty($taIDs)) {
                $allIDs = array_merge($instructorIDs, $studentIDs);
            } else {
                $allIDs = array_merge($instructorIDs, $taIDs, $studentIDs);
            }
            UTIL_setDefaultUISettings($allIDs);
            $users->close();
            mysql_close($dbConnection);
            print "<h3>Course Creation Successful!</h3>";
            printOutputPageFooting($commandState, $className);
        } else {
            print "{$errors}";
            printOutputPageFooting(CommandStates::Error, $className);
        }
    } 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);
    }
}
      <div class="container">
        <header>
          <div class="row">
            <div class="col-md-12">
              <?php 
require_once 'header.php';
?>
            </div>
          </div>
        </header>
        <hr />
        <section>
          <div class="row">
            <h3 class="text-center">
              <ins><?php 
$_SESSION['course'] = getCourseName($_GET['id']);
echo $_SESSION['course'];
?>
</ins>
            </h3>
            <br />
            <div class="col-sm-12">
            <!-- The file upload form used as target for the file upload widget -->
            <form id="fileupload" action="<?php 
echo SERVER;
?>
/controller/upload" method="POST" enctype="multipart/form-data">
              <!-- Redirect browsers with JavaScript disabled to the origin page -->
              <noscript><input type="hidden" name="redirect" value="https://blueimp.github.io/jQuery-File-Upload/"></noscript>
              <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
              <div class="row fileupload-buttonbar">
            <div class="col-md-12">
              <?php 
require_once 'header.php';
?>
            </div>
          </div>
        </header>
      </div><!-- /.container -->
      <hr />
      <div class="container">
        <section>
          <div class="row">
            <div class="col-md-12">
              <div class="text-center">
                <h2><ins><?php 
echo getCourseName($_GET['id1']);
?>
</ins></h2><br />
                <h4>
                  <?php 
$value = explode('|', $stuInfo);
?>
                  ID: <span class="text-primary"><?php 
echo htmlentities(stripcslashes($value[0]), ENT_QUOTES, 'UTF-8');
?>
</span>&nbsp;&nbsp;&nbsp;&nbsp;Name: <span class="text-primary"><?php 
echo htmlentities(stripcslashes($value[1]), ENT_QUOTES, 'UTF-8');
?>
</span>&nbsp;&nbsp;&nbsp;&nbsp;Attendence: <span class="text-primary"><?php 
echo htmlentities(stripcslashes($value[2]), ENT_QUOTES, 'UTF-8');
?>
Exemple #4
0
function processText1($text, $config, $course_value, $user_details, $order_expiration, $course_id, $plan_name, $guru_configs, $lesson_data, $lesson_id, $catid)
{
    $customer_details = getCustomerDetails($user_details["0"]["id"]);
    $site_name = $config->sitename;
    $email = $user_details["0"]["email"];
    $first_name = $customer_details["0"]["firstname"];
    $last_name = $customer_details["0"]["lastname"];
    $site_url = JURI::root();
    $user_name = $user_details["0"]["username"];
    $renew_url = JURI::root() . 'index.php?option=com_guru&controller=guruPrograms&task=buy_action&course_id=' . $course_id . '&action=renewemail';
    $product_url = "";
    $renew_term = getRenewDefaultValue($course_id, $guru_configs);
    $license_number = "1";
    $my_licenses = "";
    $product_name = getCourseName($course_id);
    if (($order_expiration == "0000-00-00 00:00:00" || $order_expiration == FALSE) && $plan_name == "Unlimited Access") {
        $expire_date = JText::_("GURU_LIFETIME_MEMBERSHIP");
    } else {
        $expire_date = $order_expiration;
        $date_format = $guru_configs["0"]["datetype"];
        $expire_date = strtotime($expire_date);
        $expire_date = date($date_format, $expire_date);
    }
    $my_orders = "";
    $subscription_term = $plan_name;
    $lesson_title = $lesson_data["0"];
    $module_lesson = $lesson_data["1"];
    $text = str_replace("[LESSON_TITLE]", $lesson_title, $text);
    $text = str_replace("[LESSON_URL]", JRoute::_("index.php?option=com_guru&view=guruTasks&catid=" . intval($catid) . "&task=view&module=" . $module_lesson . "&cid=" . $lesson_id . "&e=1", true, -1), $text);
    $text = str_replace("[SITENAME]", $site_name, $text);
    $text = str_replace("[STUDENT_EMAIL]", $email, $text);
    $text = str_replace("[STUDENT_FIRST_NAME]", $first_name, $text);
    $text = str_replace("[SITEURL]", $site_url, $text);
    $text = str_replace("[STUDENT_USER_NAME]", $user_name, $text);
    $text = str_replace("[PRODUCT_URL]", $product_url, $text);
    $text = str_replace("[STUDENT_LAST_NAME]", $last_name, $text);
    $text = str_replace("[RENEW_TERM]", $renew_term, $text);
    $text = str_replace("[RENEW_URL]", $renew_url, $text);
    $text = str_replace("[LICENSE_NUMBER]", $license_number, $text);
    $text = str_replace("[MY_LICENSES]", $my_licenses, $text);
    $text = str_replace("[COURSE_NAME]", $product_name, $text);
    $text = str_replace("[EXPIRE_DATE]", $expire_date, $text);
    $text = str_replace("[MY_ORDERS]", $my_orders, $text);
    $text = str_replace("[SUBSCRIPTION_TERM]", $subscription_term, $text);
    $course_url = JRoute::_("index.php?option=com_guru&controller=guruPrograms&task=view&cid=" . $course_id, true, -1);
    $app = JFactory::getApplication();
    if ($app->isAdmin()) {
        $course_url = JURI::root() . "index.php?option=com_guru&controller=guruPrograms&task=view&cid=" . intval($course_id);
    }
    $course_href = '<a href="' . $course_url . '" targetr="_blank">' . $course_url . '</a>';
    $text = str_replace("[COURSE_URL]", $course_href, $text);
    $text = str_replace("[MY_COURSES]", JURI::root() . "index.php?option=com_guru&view=guruorders&layout=mycourses", $text);
    $text = str_replace("[MY_ORDERS]", JURI::root() . "index.php?option=com_guru&view=guruorders&layout=myorders", $text);
    return $text;
}