示例#1
0
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod.html) this function
 * will create a new instance and return the id number
 * of the new instance.
 *
 * @param object $instance An object from the form in mod.html
 * @return int The id of the newly inserted mapleta record
 **/
function mapleta_add_instance($mapleta) {

	# May have to add extra stuff in here #

	$mapleta->timemodified = time();

	$id = mapleta_insert_record("mapleta", $mapleta);
	$mapleta->id = $id;
	
	mapleta_grade_item_update($mapleta);

	return $id;
}
示例#2
0
					print_error('wrong_data_format','mapleta', $errorURL);
			}

			mapleta_ws_disconnect($connect->session, $connect);

			if($status->code == 1) {
				print_error($status->message, 'mapleta', $errorURL);
			} else {
				$db_object= new mapleta_course_map();
				$db_object->courseid= $course->id;
				$db_object->classid= $new_class[0]->id;
				$db_object->classname= mapleta_urlencode($new_class[0]->name);
				
//				var_dump($db_object);
				
				if(!mapleta_insert_record('mapleta_course_map', $db_object)) {
					print_error('error_storing_mapping','mapleta', $errorURL);
				} else {
					echo "<br/><center><strong>Course $course->fullname has been successfully mapped to Maple TA class '".$new_class[0]->name."'.</strong></center><br/>";
				}
			}
		}
	} else { // Not admin or teacher
		print_error('not_authorized_for_action', 'mapleta', $errorURL);
	}
} else
	if($action == 'delete') { // Course already mapped
		if(mapleta_is_administrator($id) || mapleta_is_teacher($id)) {
			echo "<form method='post' action='course_mapping.php'>";
			echo "<input type='hidden' name='id' value='$id'/>";
			echo "<input type='hidden' name='action' value='dodelete'/>";