Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Drag-and-drop markers classes for dealing with shapes on the server side.

Author: Jamie Pratt <me@jamiep.org>
Copyright: 2012 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 484 lines (17 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 5 classes

qtype_ddmarker_shape:: (11 methods):
  __construct()
  inside_width_height()
  is_only_numbers()
  is_point_in_bounding_box()
  get_coords_interpreter_error()
  name()
  human_readable_name()
  human_readable_coords_format()
  shape_options()
  exists()
  create()

qtype_ddmarker_shape_rectangle:: (4 methods):
  __construct()
  outlying_coords_to_test()
  is_point_in_shape()
  center_point()

qtype_ddmarker_shape_circle:: (4 methods):
  __construct()
  outlying_coords_to_test()
  is_point_in_shape()
  center_point()

qtype_ddmarker_shape_polygon:: (5 methods):
  __construct()
  outlying_coords_to_test()
  is_point_in_shape()
  is_left()
  center_point()

qtype_ddmarker_point:: (2 methods):
  __construct()
  dist()


Class: qtype_ddmarker_shape  - X-Ref

Base class to represent a shape.

__construct($coordsstring)   X-Ref
No description

inside_width_height($widthheight)   X-Ref
No description

is_only_numbers()   X-Ref
Test if all passed parameters consist of only numbers.

return: bool True if only numbers

is_point_in_bounding_box($pointxy, $xleftytop, $xrightybottom)   X-Ref
Checks if the point is within the bounding box made by top left and bottom right

param: array $pointxy Array of the point (x, y)
param: array $xleftytop Top left point of bounding box
param: array $xrightybottom Bottom left point of bounding box
return: bool

get_coords_interpreter_error()   X-Ref
Gets any coordinate error

return: string|bool String of the error or false if there is no error

name()   X-Ref
Returns the name of the shape.

return: string

human_readable_name($lowercase = false)   X-Ref
Return a human readable name of the shape.

param: bool $lowercase True if it should be lowercase.
return: string

human_readable_coords_format()   X-Ref
No description

shape_options()   X-Ref
No description

exists($shape)   X-Ref
Checks if the passed shape exists.

param: string $shape The shape name
return: bool

create($shape, $coordsstring)   X-Ref
Creates a new shape of the specified type.

param: string $shape The shape to create
param: string $coordsstring The string describing the coordinates
return: object

Class: qtype_ddmarker_shape_rectangle  - X-Ref

Class to represent a rectangle.

__construct($coordsstring)   X-Ref
No description

outlying_coords_to_test()   X-Ref
No description

is_point_in_shape($xy)   X-Ref
No description

center_point()   X-Ref
No description

Class: qtype_ddmarker_shape_circle  - X-Ref

Class to represent a circle.

__construct($coordsstring)   X-Ref
No description

outlying_coords_to_test()   X-Ref
No description

is_point_in_shape($xy)   X-Ref
No description

center_point()   X-Ref
No description

Class: qtype_ddmarker_shape_polygon  - X-Ref

Class to represent a polygon.

__construct($coordsstring)   X-Ref


outlying_coords_to_test()   X-Ref
No description

is_point_in_shape($xy)   X-Ref
No description

is_left(qtype_ddmarker_point $start, qtype_ddmarker_point $end,qtype_ddmarker_point $point)   X-Ref
Tests if a point is left / on / right of an infinite line.

param: qtype_ddmarker_point $start first of two points on the infinite line.
param: qtype_ddmarker_point $end second of two points on the infinite line.
param: qtype_ddmarker_point $point the oint to test.
return: number > 0 if the point is left of the line.

center_point()   X-Ref
No description

Class: qtype_ddmarker_point  - X-Ref

Class to represent a point.

__construct($x, $y)   X-Ref
No description

dist($other)   X-Ref
Return the distance between this point and another