Example #1
0
 static function sms_api($data)
 {
     // this returns the sms url appropriate for the item element (inner array) of the return from module_code_translate function
     if ($data[0] != 'SMS') {
         return '';
     }
     $SMS = SmsUtils::GetSmsUtils();
     $SMS->set_module($data[2]);
     return $SMS->url;
 }
Example #2
0
 /**
  * Creates a new module.
  * 
  * @param integer $moduleid           - The code of the module.
  * @param string $fullname            - The full name of the module.
  * @param integer $active             - Is the module active or inactive.
  * @param integer $schoolID           - Which school the module belongs to.
  * @param string $vle_api             - Which curriculum map or VLE to use for learning objectives.
  * @param string $sms_api             - Which SMS system to link to.
  * @param integer $selfEnroll         - Can students self-enrol in the module.
  * @param bool $peer                  - Is Peer Review turned on.
  * @param bool $external              - Is External Examiner turned on.
  * @param bool $stdset                - Is Standard Setting turned on.
  * @param bool $mapping               - Is mapping turned on. 
  * @param integer $neg_marking        - Can negative marking be used in questions.
  * @param string $ebel_grid_template  - Which Ebel grid to assign (optional).
  * @param object $db                  - MySQLi database connection.
  * @param integer $sms_import         - 
  * @param integer $timed_exams        - Are timed summative exams allowed.
  * @param integer $exam_q_feedback    - Is question-based feedback allowed for summative exams.
  * @param integer $add_team_members   - Are team members allowed to add others.
  * @param integer $map_level          - What level to link to in the curriculum map.
  * @param string $academic_year_start - Day the module changes academic year.
  * 
  * @return boolean - True if module successfully added.
  */
 public function add_modules($moduleid, $fullname, $active, $schoolID, $vle_api, $sms_api, $selfEnroll, $peer, $external, $stdset, $mapping, $neg_marking, $ebel_grid_template, $db, $sms_import = 0, $timed_exams = 0, $exam_q_feedback = 1, $add_team_members = 1, $map_level = 0, $academic_year_start = '07/01')
 {
     // Return false if missing madatory fields. schoolid is actually a number
     if ($moduleid == '' or $fullname == '' or $schoolID === '') {
         return false;
     }
     // Don't create a duplicate module with the same module ID.
     if (module_utils::module_exists($moduleid, $db) !== false) {
         return false;
     }
     $checklist = '';
     if ($peer == true) {
         $checklist .= ',peer';
     }
     if ($external == true) {
         $checklist .= ',external';
     }
     if ($stdset == true) {
         $checklist .= ',stdset';
     }
     if ($mapping == true) {
         $checklist .= ',mapping';
     }
     if ($checklist != '') {
         $tmp_checklist = substr($checklist, 1);
     }
     $result = $db->prepare("INSERT INTO modules VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?)");
     $result->bind_param('ssisssiiiiiiiis', $moduleid, $fullname, $active, $vle_api, $tmp_checklist, $sms_api, $selfEnroll, $schoolID, $neg_marking, $ebel_grid_template, $timed_exams, $exam_q_feedback, $add_team_members, $map_level, $academic_year_start);
     $result->execute();
     $result->close();
     if ($db->errno != 0) {
         return "failed at insert";
         return false;
     }
     $idMod = $db->insert_id;
     if ($sms_import == 1 and $sms_api != '') {
         $SMS = SmsUtils::GetSmsUtils();
         $SMS->update_module_enrolement($moduleid, $idMod, $sms_api, $db);
     }
     return $idMod;
 }
Example #3
0
 static function module_code_translate($c_internal_id, $course_title = ' ')
 {
     if (stripos($c_internal_id, ' ') !== false) {
         self::invalid_module_code($c_internal_id, array(), 'initial blank check');
     }
     // only get the shortname through  (courseID is only probably accessible via specific moodle webservices api
     // shortname for real module try XXXXXX-YY-ZZZWWWW  WHERE XXXXXX is saturn code YY is country rest we dont care about.
     // shortname for non module VV-XXXXX-XXXXX-YY-WWWW WHERE XXXXXXXXXX is the fake 'module code'  YYY is country VV is DEPT 2 letter code
     // shortname for metamodules is XXXXXX-YY-XXXXXX-YY-XXXXXXX-YYY-ZZZWWWWW where the set of XXXXXX, YY are unknown
     // convert vle module format into rogo format
     $exploded = explode('-', $c_internal_id);
     $length = strlen($exploded[0]);
     $fin = strlen($course_title);
     if (strpos($course_title, '(') !== false) {
         $fin = strpos($course_title, '(') - 1;
     }
     $course_title = substr($course_title, 0, $fin);
     if ($length < 6) {
         //not saturn code
         $campus = '';
         //this should mean its a fake course
         $modcode = '';
         for ($a = 1; $a < count($exploded); $a++) {
             if (in_array(strtoupper($exploded[$a]), array('UK', 'MY', 'CN'))) {
                 $campus = strtoupper($exploded[$a]);
                 break;
             }
             $modcode = $modcode . '-' . $exploded[$a];
         }
         $modcode = substr($modcode, 1);
         $schoolname = 'UNKNOWN School';
         if (isset(self::$dept_code[$exploded[0]])) {
             $schoolname = self::$dept_code[$exploded[0]];
         }
         $selfreg = 1;
         if ($course_title == ' ') {
             $course_title = 'MISSING: ';
         }
         $data[] = array('Manual', $modcode, $campus, $schoolname, $selfreg, $course_title);
     } else {
         $a = 0;
         $b = 0;
         $data = array();
         $selfreg = 0;
         while (isset($exploded[$a])) {
             if (strlen($exploded[$a]) == 6) {
                 //saturn codes are 6 chars
                 // data is
                 $data[$b++] = array('SMS', $exploded[$a], 'CampusMissing', 'UNKNOWN School', $selfreg, "MISSING:{$course_title}");
             } elseif (strlen($exploded[$a]) == 2) {
                 // probably campus check
                 if (in_array(strtoupper($exploded[$a]), array('UK', 'MY', 'CN'))) {
                     for ($c = 0; $c < $b; $c++) {
                         if ($data[$c][2] == 'CampusMissing') {
                             $data[$c][2] = strtoupper($exploded[$a]);
                         }
                     }
                 }
             }
             $a++;
         }
     }
     foreach ($data as $k => $v) {
         if (substr($v[5], 0, 8) == 'MISSING:' and $v[0] == 'SMS') {
             $sms = SmsUtils::GetSmsUtils();
             if ($sms === false) {
                 $data[$k][5] = "SATURN " . $data[$k][5];
             } else {
                 $sms->set_module($v[2]);
                 $returned = $sms->get_module_info($v[1]);
                 if ($returned !== false) {
                     $data[$k][5] = $returned[1];
                     $data[$k][3] = $returned[2];
                 } else {
                     $data[$k][5] = "SATURN " . $data[$k][5];
                 }
             }
         }
         if ($data[$k][1] == '') {
             self::invalid_module_code($c_internal_id, $data, 'during loop');
         }
         if ($v[2] == 'MY') {
             $data[$k][1] = $data[$k][1] . '_UNMC';
         } elseif ($v[2] == 'CN') {
             $data[$k][1] = $data[$k][1] . '_UNNC';
         }
     }
     if (count($data) == 1 and substr($data[0][5], 0, 8) == 'MISSING:' and strlen($data[0][5]) > 9) {
         $data[0][5] = substr($data[0][5], 8);
     }
     // return the data
     // returning an array containing an array, description of inner array
     // first is 'Manual' or 'SMS' indicating if its not or it is a manual add or a live SMS based module
     // second is the module code
     // third is campus
     // fourth is School it belongs to as text
     // fifth is if its self registration module
     // sixth is the module title.  if it starts MISSING: then there is need for manual intervention to complete this correctly
     if (count($data) === 0) {
         self::invalid_module_code($c_internal_id, $data, 'no returned data');
     }
     return $data;
 }
Example #4
0
    $_REQUEST['lookuptesttype'] = 'user';
}
$list = '';
$newdata = new stdClass();
foreach ($_REQUEST as $key => $value) {
    if ($key != 'lookuptesttype' and $key != 'ROGO_PW') {
        $newdata->{$key} = $value;
        $list = $list . " {$key} = {$value}";
    }
}
echo "use lookuptesttype to set type of lookup anything else taken as a key value pair<br>";
echo "<h1>looking up {$_REQUEST['modulecode']}</h1>";
$configObj = Config::get_instance();
$lookup = Lookup::get_instance($configObj, $mysqli);
$newdata = new stdClass();
$sms_connection = SmsUtils::GetSmsUtils();
if ($sms_connection === false) {
    print "<h2>No SMS configuration set</h2>";
    exit;
}
var_dump($sms_connection);
$out = $sms_connection->get_module($_REQUEST['modulecode']);
var_dump($out);
exit;
if (!isset($_REQUEST['lookuptesttype'])) {
    $_REQUEST['lookuptesttype'] = 'user';
}
$list = '';
foreach ($_REQUEST as $key => $value) {
    if ($key != 'lookuptesttype' and $key != 'ROGO_PW') {
        $newdata->{$key} = $value;