Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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: 3 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

return: bool
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

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.

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

human_readable_coords_format()   X-Ref
No description

shape_options()   X-Ref
No description

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

return: bool
param: string $shape The shape name

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

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

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.

return: number > 0 if the point is left of the 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.

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