Ejemplo n.º 1
0
/**
 * Calculates the maximum and minimum bounds of the specified LoginZone
 * Returns the bounds as a numeric array of two associate array vectors: ($max, $min).
 * (Or returns false if no LoginZone position/size could be found in the Moodle configuration table).
 * @param string $pos A string vector giving the position of the LoginZone
 * @param string $size A string vector giving the size of the LoginZone
 * @return array
 */
function sloodle_login_zone_bounds($pos, $size)
{
    // Make sure the parameters are valid types
    if ($pos == FALSE || $size == FALSE) {
        return FALSE;
    }
    // Convert both to arrays
    $posarr = sloodle_vector_to_array($pos);
    $sizearr = sloodle_vector_to_array($size);
    // Calculate the bounds
    $max = array();
    $max['x'] = $posarr['x'] + $sizearr['x'] / 2 - 2;
    $max['y'] = $posarr['y'] + $sizearr['y'] / 2 - 2;
    $max['z'] = $posarr['z'] + $sizearr['z'] / 2 - 2;
    $min = array();
    $min['x'] = $posarr['x'] - $sizearr['x'] / 2 + 2;
    $min['y'] = $posarr['y'] - $sizearr['y'] / 2 + 2;
    $min['z'] = $posarr['z'] - $sizearr['z'] / 2 + 2;
    return array($max, $min);
}
 /**
  * Construct a text summary of this submission.
  * @param bool $return If TRUE (default) then the text will be submitted instead of printed.
  * @return string If parameter $return was TRUE, then it returns the string. Otherwise, an empty string.
  */
 function text_summary($return = true)
 {
     // Make sure something is loaded
     if (!$this->is_loaded) {
         $text = get_string('emptysubmission', 'assignment');
     } else {
         $text = "Object name: <b>{$this->obj_name}</b><br><br>";
         $text .= "Submitted to: {$this->primdrop_name}<br>";
         $text .= " <i>({$this->primdrop_uuid})</i><br><br>";
         $arr = sloodle_vector_to_array($this->primdrop_pos);
         if (!$arr) {
             $arr = array('x' => 0, 'y' => 0, 'z' => 0);
         } else {
             $arr['x'] = round($arr['x']);
             $arr['y'] = round($arr['y']);
             $arr['z'] = round($arr['z']);
         }
         $loc = "secondlife://{$this->primdrop_region}/{$arr['x']}/{$arr['y']}/{$arr['z']}";
         $text .= "<b><a href=\"{$loc}\">{$loc}</a></b><br>";
     }
     if ($return) {
         return $text;
     }
     echo $text;
     return '';
 }
Ejemplo n.º 3
0
if ($sloodleobjname == null || empty($sloodleobjname)) {
    // No - just checking if the user can submit
    $sloodle->response->set_status_code(1);
    $sloodle->response->set_status_descriptor('OK');
    $sloodle->response->add_data_line('Checked assignment status');
    $sloodle->response->render_to_output();
    exit;
}
// Object being submitted - fetch our other data
$sloodleprimcount = (int) $sloodle->request->required_param('sloodleprimcount');
$sloodleprimdropname = $sloodle->request->required_param('sloodleprimdropname');
$sloodleprimdropuuid = $sloodle->request->required_param('sloodleprimdropuuid');
$sloodleregion = $sloodle->request->required_param('sloodleregion');
$sloodlepos = $sloodle->request->required_param('sloodlepos');
// Make sure the position is valid
$arr = sloodle_vector_to_array($sloodlepos);
if (!$arr) {
    $sloodlepos = '<0,0,0>';
} else {
    $sloodlepos = sloodle_round_vector($sloodlepos);
}
// Submit all the data
if ($sloodle->module->submit($sloodle->user, $sloodleobjname, $sloodleprimcount, $sloodleprimdropname, $sloodleprimdropuuid, $sloodleregion, $sloodlepos)) {
    // OK
    $sloodle->response->set_status_code(1);
    $sloodle->response->set_status_descriptor('OK');
    $sloodle->response->add_data_line('SUBMITTED OBJECT');
} else {
    // Error
    $sloodle->response->set_status_code(-103);
    $sloodle->response->set_status_descriptor('SYSTEM');
Ejemplo n.º 4
0
 /**
  * Finds the user identified by LoginZone allocation, and loads it into the given user object.
  * Note: does not delete the allocation.
  * @param string $pos Absolute position vector (relative to sim, not to LoginZone)
  * @param SloodleUser &$user The user object which will be manipulated (by reference)
  * @return bool True if successful, or false otherwise
  */
 function load_user_by_loginzone($pos, &$user)
 {
     // Calculate the relative position of the allocation
     $abspos = sloodle_vector_to_array($pos);
     $loginzonepos = sloodle_vector_to_array($this->sloodle_course_data->loginzonepos);
     $relpos = array('x' => $abspos['x'] - $loginzonepos['x'], 'y' => $abspos['y'] - $loginzonepos['y'], 'z' => $abspos['z'] - $loginzonepos['z']);
     $relpos = sloodle_array_to_vector($relpos);
     // Attempt to find a matching LoginZone position in the database
     $rec = get_record('sloodle_loginzone_allocation', 'course', $this->get_course_id(), 'position', $relpos);
     if (!$rec) {
         return false;
     }
     // Load the user
     return $user->load_user($rec->userid);
 }