$array_request= $out->list; if (!empty($array_request)) { if (!mapleta_ws_check_signature($out->timestamp, $out->signature)) { $message = "Invalid or expired request."; mapleta_ws_send_error($message); return; } $element = $array_request[0]; $subelement = $element->list[0]; if ($mapleta_course_map = mapleta_get_record('mapleta_course_map', 'classid', (int)$element->classId)) { if($mapleta = mapleta_get_record('mapleta', 'assignmentid', (int)$element->id)) { if ($user = mapleta_get_record('user', 'username', $subelement->userLogin)) { $mapleta->name = $element->name; $mapleta->assignmentmode = $element->mode; $mapleta->modedescription = $element->modeDescription; $mapleta->passingscore = $element->passingScore; $mapleta->totalpoints = $element->totalPoints; $mapleta->timelimit = $element->timeLimit; $mapleta->starttime = $element->start; $mapleta->endtime = $element->end; $mapleta->policy = $element->policy; $grades = array ( 'id' => $user->id, 'userid' => $user->id, 'rawgrade' => $subelement->score,
function definition() { global $COURSE, $CFG; $mform= & $this->_form; $mtasession= null; $valid= true; $errorURL="$CFG->wwwroot/course/view.php?id=$COURSE->id"; if (!empty($this->_instance)) { if($mapleta = mapleta_get_record('mapleta', 'id', (int)$this->_instance)) { $assignmentid = $mapleta->assignmentid; } else { print_error('corrupted_assignment', 'mapleta', $errorURL); } } else { $assignmentid=0; } if($course_mapping= mapleta_get_record('mapleta_course_map', 'courseid', $COURSE->id)) { $mform->addElement('hidden', 'course', $course_mapping->courseid); $connect= mapleta_ws_connect_to_class($COURSE->id, $course_mapping->classid); if($connect == null) { print_error('error_connecting_to_ta', 'mapleta', $errorURL); } else if($connect->code == 1) { print_error($connect->message, 'mapleta', $errorURL); } $status= new mapleta_status_response(); $mta_assignments= mapleta_ws_get_assignments($course_mapping->classid, $connect->session, $status); if($status->code == 1) { mapleta_ws_disconnect($connect->session, $connect); print_error($status->message, 'mapleta', $errorURL); } else if($status->code == 100) { mapleta_ws_disconnect($connect->session, $connect); print_error('no_assignments_in_class', 'mapleta', $errorURL); } mapleta_ws_disconnect($connect->session, $connect); $mform->addElement('header', 'header1', get_string('availableassignments', 'mapleta')); $mform->closeHeaderBefore('name'); $mform->addElement('html', "<div style='text-align: center'><table id='mapleta-config' class='generaltable boxaligncenter' cellpadding='5'>"); $mform->addElement('html', "<tr>"); $mform->addElement('html', "<th class='header c0'>Name</th>"); $mform->addElement('html', "<th class='header c0'>Type</th>"); $mform->addElement('html', "<th class='header c0'>Availability</th>"); $mform->addElement('html', "<th class='header c0'>Time Limit</th>"); $mform->addElement('html', "</tr>"); $counter = 0; $default_index = -1; foreach($mta_assignments as $mta_assignment) { $mform->addElement('html', "<tr>"); $search = array("\"","'"); $replace_by_entities_number = array(""","'"); $local_name = str_replace($search,$replace_by_entities_number,$mta_assignment->name); // $local_name = addslashes ($mta_assignment->name); $local_modeDescription = str_replace($search,$replace_by_entities_number,$mta_assignment->modeDescription); $local_start = addslashes ($mta_assignment->start); $local_end = addslashes ($mta_assignment->end); $local_policy = str_replace($search,$replace_by_entities_number,$mta_assignment->policy); $attributes="javascript:{document.getElementsByName('assignmentid')[0].value='$mta_assignment->id';" . "document.getElementsByName('name')[0].value='$local_name';" . "document.getElementsByName('assignmentmode')[0].value='$mta_assignment->mode';" . "document.getElementsByName('modedescription')[0].value='$local_modeDescription';" . "document.getElementsByName('passingscore')[0].value='$mta_assignment->passingScore';" . "document.getElementsByName('totalpoints')[0].value='$mta_assignment->totalPoints';" . "document.getElementsByName('timelimit')[0].value='$mta_assignment->timeLimit';" . "document.getElementsByName('starttime')[0].value='$local_start';" . "document.getElementsByName('endtime')[0].value='$local_end';" . "document.getElementsByName('policy')[0].value='$local_policy';}"; $attributes='onclick="'.$attributes.'"'; if ($assignmentid == 0) { if ($counter == 0) { $attributes = $attributes; $checked = 'checked="checked"'; $default_index = 0; } else { $checked = ''; } } else { if ($mta_assignment->id == $assignmentid) { $attributes = $attributes; $checked = 'checked="checked"'; $default_index = $counter; } else { $attributes = $attributes." disabled"; $checked = 'disabled="disabled"'; } } if ($default_index >= 0 && empty($script)) { $script="<script>" . "document.getElementsByName('assignmentid')[0].value='$mta_assignment->id';" . "document.getElementsByName('name')[0].value='$local_name';" . "document.getElementsByName('assignmentmode')[0].value='$mta_assignment->mode';" . "document.getElementsByName('modedescription')[0].value='$local_modeDescription';" . "document.getElementsByName('passingscore')[0].value='$mta_assignment->passingScore';" . "document.getElementsByName('totalpoints')[0].value='$mta_assignment->totalPoints';" . "document.getElementsByName('timelimit')[0].value='$mta_assignment->timeLimit';" . "document.getElementsByName('starttime')[0].value='$local_start';" . "document.getElementsByName('endtime')[0].value='$local_end';" . "document.getElementsByName('policy')[0].value='$local_policy';". "</script>"; } $counter = $counter + 1; $mform->addElement('html', "<td align='left' class='cell c0'>"); $mform->addElement('html', "<input type='radio' name='assgnid' value='$mta_assignment->id' $attributes $checked/> <strong>$mta_assignment->name</strong>"); $mform->addElement('html', "</td>"); $mform->addElement('html', "<td align='center' class='cell c0'>$mta_assignment->modeDescription</td>"); if ($mta_assignment->start != null && $mta_assignment->end != null) { $mform->addElement('html', "<td align='center' class='cell c0'>".date("d/m/y h:i A",$mta_assignment->start/1000)." - ".date("d/m/y h:i A",$mta_assignment->end/1000)."</td>"); } else if ($mta_assignment->start != null) { $mform->addElement('html', "<td align='center' class='cell c0'>After ".date("d/m/y h:i A",$mta_assignment->start/1000)."</td>"); } else if ($mta_assignment->end != null) { $mform->addElement('html', "<td align='center' class='cell c0'>Before ".date("d/m/y h:i A",$mta_assignment->end/1000)."</td>"); } else { $mform->addElement('html', "<td align='center' class='cell c0'>Unlimited</td>"); } if ($mta_assignment->timeLimit != '-1') { $mform->addElement('html', "<td align='center' class='cell c0'>$mta_assignment->timeLimit minutes</td>"); } else { $mform->addElement('html', "<td align='center' class='cell c0'>N/A</td>"); } $mform->addElement('html', "</tr>"); } $mform->addElement('html', "</table></div>"); $mform->addElement('hidden', 'assignmentid', $mta_assignments[$default_index]->id); $mform->addElement('hidden', 'name', $mta_assignments[$default_index]->name); $mform->addElement('hidden', 'assignmentmode', $mta_assignments[$default_index]->mode); $mform->addElement('hidden', 'modedescription', $mta_assignments[$default_index]->modeDescription); $mform->addElement('hidden', 'passingscore', $mta_assignments[$default_index]->passingScore); $mform->addElement('hidden', 'totalpoints', $mta_assignments[$default_index]->totalPoints); $mform->addElement('hidden', 'timelimit', $mta_assignments[$default_index]->timeLimit); $mform->addElement('hidden', 'starttime', $mta_assignments[$default_index]->start); $mform->addElement('hidden', 'endtime', $mta_assignments[$default_index]->end); $mform->addElement('hidden', 'policy', $mta_assignments[$default_index]->policy); $mform->addElement('html', $script); $this->standard_coursemodule_elements(); $this->add_action_buttons(); } else { print_error('course_not_mapped', 'mapleta', $errorURL); } }
/** * This page lists all the instances of mapleta in a particular course * * @author * @version $Id: index.php,v 1.5 2006/08/28 16:41:20 mark-nielsen Exp $ * @package mapleta **/ /// Replace mapleta with the name of your module require_once("../../config.php"); require_once("lib.php"); $id = required_param('id', PARAM_INT); // course if (! $course = mapleta_get_record("course", "id", $id)) { print_error('course_id_incorrect', 'mapleta'); } require_login($course->id); add_to_log($course->id, "mapleta", "view all", "index.php?id=$course->id", ""); /// Get all required stringsmapleta $strmapletas = get_string("modulenameplural", "mapleta"); $strmapleta = get_string("modulename", "mapleta"); /// Print the header
/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure **/ function mapleta_delete_instance($id) { if(!$mapleta= mapleta_get_record("mapleta", "id", "$id")) { return false; } $result= true; # Delete any dependent records here # if(!mapleta_delete_records("mapleta", "id", "$mapleta->id")) { $result= false; } mapleta_grade_item_delete($mapleta); return $result; }
function get_content() { global $CFG; global $COURSE; global $USER; if ($this->content != null) { return $this->content; } $this->content = new stdClass(); if (mapleta_get_role($COURSE->id) == 'UNSET') { $this->content->text = ''; $this->content->footer = ''; return $this->content; } if (!mapleta_ws_ping()) { $this->content->text = '<div class="info"><font color="red">' . get_string('mapleta_not_available', 'block_mapleta_course_tools') . '</font></div><br/>'; $this->content->footer = '<div class="info">' . get_string('contact_sys_admin', 'block_mapleta_course_tools') . '</div><br/>'; return $this->content; } $course_mapping = mapleta_get_record('mapleta_course_map', 'courseid', $COURSE->id); if ($COURSE->format != 'site' && !$course_mapping) { if (mapleta_is_administrator($COURSE->id) || mapleta_is_teacher($COURSE->id)) { $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=create">' . get_string('map_the_course', 'block_mapleta_course_tools') . '</a></div>'; $this->content->text = '<div class="info"><font color="red">' . get_string('course_is_not_mapped', 'block_mapleta_course_tools') . '</font></div><br/>'; } } else { if (mapleta_is_administrator($COURSE->id)) { if ($COURSE->format != 'site') { $params = "wsActionID=classHome&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('class_homepage', 'block_mapleta_course_tools') . '</a></div><br/><hr>'; // . '<a href="'.$CFG->wwwroot.'/mod/mapleta/grade.php">Grade</a>'; $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=delete">' . get_string('remove_course_mapping', 'block_mapleta_course_tools') . '</a></div>'; } else { $params = "wsActionID=systemHome&wsClassId=-1&wsCourseId={$COURSE->id}"; $this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('system_homepage', 'block_mapleta_course_tools') . '</a>'; } } else { if (mapleta_is_teacher($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=classHome&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('class_homepage', 'block_mapleta_course_tools') . '</a></div><br/><hr>'; $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=delete">' . get_string('remove_course_mapping', 'block_mapleta_course_tools') . '</a></div>'; } else { if (mapleta_is_proctor($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=proctorTools&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('proctor_tools', 'block_mapleta_course_tools') . '</a></div><br/>'; $this->content->footer = ''; } else { if (mapleta_is_student($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=gradeBook&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}&showStudents=true&actionID=4&uid={$USER->username}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('gradebook', 'block_mapleta_course_tools') . '</a></div><br/>'; $this->content->footer = ''; } else { $this->content->text = ''; $this->content->footer = ''; } } } } } return $this->content; }
$status= new mapleta_status_response(); $new_class= array(); switch($mapping_type) { case 1 : //Create a child of the featured class. if($featured_class) { $new_class= mapleta_ws_create_class($connect->session, $featured_class, 0, $course->fullname, $course->id, $status); } else { print_error('missing_parent_class','mapleta', $errorURL); } break; case 2 : //Map to existing class if($existing_class) { if ($mapleta_course_map = mapleta_get_record('mapleta_course_map', 'classid', $existing_class)) { print_error('class_already_mapped', 'mapleta', $errorURL); } else { $new_class= mapleta_ws_create_class($connect->session, 0, $existing_class, $course->fullname, $course->id, $status); } } else { print_error('missing_class','mapleta', $errorURL); } break; case 3 : //Create brand new class $new_class= mapleta_ws_create_class($connect->session, 0, 0, $course->fullname, $course->id, $status); break; default : mapleta_ws_disconnect($connect->session, $connect);
if ($course->category) { $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->"; } else { $navigation = ''; } $strmapletas = get_string("modulenameplural", "mapleta"); $strmapleta = get_string("modulename", "mapleta"); /// Print the main part of the page if (!$course_mapping = mapleta_get_record('mapleta_course_map', 'courseid', $course->id)) { print_error('course_not_mapped', 'mapleta', $errorURL); } if (!mapleta_is_student($course->id)) { print_error('not_authorized_for_action', 'mapleta', $errorURL); } $connect = mapleta_ws_connect_to_class($course->id, $course_mapping->classid); if ($connect == null) { print_error('error_connecting_to_ta', 'mapleta', $errorURL); } else if ($connect->code == 1) { print_error($connect->message, 'mapleta', $errorURL); }