core_grades/edittree_weight

This module provides functionality for managing weight calculations and adjustments for grade items.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Members

(static, constant) init

Source:

Initializes the weight management module with optional configuration.

(inner) decimalSeparator :string

Source:

The character used as the decimal separator for number formatting.

Type:
  • string

(inner, constant) grade :Object

Source:
Properties:
Name Type Description
aggregation Object

Aggregation settings.

Properties
Name Type Description
sum number

Aggregation method: sum.

type Object

Grade type settings.

Properties
Name Type Description
none number

Grade type: none.

value number

Grade type: value.

scale number

Grade type: scale.

An object representing grading-related constants. The same as what's defined in lib/grade/constants.php.

Type:
  • Object

(inner) oldExtraCreditCalculation :boolean

Source:

This setting indicates if we should use algorithm prior to MDL-49257 fix for calculating extra credit weights. Even though the old algorithm has bugs in it, we need to preserve existing grades.

Type:
  • boolean

(inner, constant) selectors :Object

Source:

Selectors.

Type:
  • Object

Methods

(inner) formatFloat(number, decimalPointsopt, minDecimalsopt) → {string}

Source:

Formats a floating-point number as a string with the specified number of decimal places. Unnecessary trailing zeros are removed up to the specified minimum number of decimal places.

Parameters:
Name Type Attributes Default Description
number number

The float value to be formatted.

decimalPoints number <optional>
3

The number of decimal places to use.

minDecimals number <optional>
1

The minimum number of decimal places to use.

Returns:

The formatted weight value with the specified decimal places.

Type
string

(inner) parseWeight(weightString) → {number}

Source:

Parses a weight string and returns a normalized float value.

Parameters:
Name Type Description
weightString string

The weight as a string, possibly with localized formatting.

Returns:

The parsed weight as a float. If parsing fails, returns 0.

Type
number

(inner) recalculateNaturalWeights(categoryElement)

Source:

Recalculates the natural weights for grade items within a given category.

Parameters:
Name Type Description
categoryElement HTMLElement

The DOM element representing the category.