~ubuntu-branches/ubuntu/trusty/moodle/trusty

« back to all changes in this revision

Viewing changes to lib/grade/grade_category.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-01-21 13:40:52 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140121134052-ym2qvsp2cd9vq0p6
Tags: 2.5.4-1
* New upstream release, fixing security issues:
  - MSA-14-0001 Config passwords visibility issue [CVE-2014-0008]
  - MSA-14-0002 Group constraints lacking in "login as" [CVE-2014-0009]
  - MSA-14-0003 CSRF vulnerability in profile fields [CVE-2014-0010]
* Move /var/lib/moodle directory into package.
* Revert back to bundled yui3. Unfortunately, version in Debian and
  of upstream are not compatible (closes: #735312).

Show diffs side-by-side

added added

removed removed

Lines of Context:
967
967
     *
968
968
     * @return bool True if extra credit used
969
969
     */
970
 
    function is_extracredit_used() {
971
 
        return ($this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2
972
 
             or $this->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN
973
 
             or $this->aggregation == GRADE_AGGREGATE_SUM);
 
970
    public function is_extracredit_used() {
 
971
        return self::aggregation_uses_extracredit($this->aggregation);
 
972
    }
 
973
 
 
974
    /**
 
975
     * Returns true if aggregation passed is using extracredit.
 
976
     *
 
977
     * @param int $aggregation Aggregation const.
 
978
     * @return bool True if extra credit used
 
979
     */
 
980
    public static function aggregation_uses_extracredit($aggregation) {
 
981
        return ($aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2
 
982
             or $aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN
 
983
             or $aggregation == GRADE_AGGREGATE_SUM);
974
984
    }
975
985
 
976
986
    /**
979
989
     * @return bool True if an aggregation coefficient is being used
980
990
     */
981
991
    public function is_aggregationcoef_used() {
982
 
        return ($this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN
983
 
             or $this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2
984
 
             or $this->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN
985
 
             or $this->aggregation == GRADE_AGGREGATE_SUM);
 
992
        return self::aggregation_uses_aggregationcoef($this->aggregation);
 
993
 
 
994
    }
 
995
 
 
996
    /**
 
997
     * Returns true if aggregation uses aggregationcoef
 
998
     *
 
999
     * @param int $aggregation Aggregation const.
 
1000
     * @return bool True if an aggregation coefficient is being used
 
1001
     */
 
1002
    public static function aggregation_uses_aggregationcoef($aggregation) {
 
1003
        return ($aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN
 
1004
             or $aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2
 
1005
             or $aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN
 
1006
             or $aggregation == GRADE_AGGREGATE_SUM);
986
1007
 
987
1008
    }
988
1009
 
1573
1594
 
1574
1595
            //weight and extra credit share a column :( Would like a default of 1 for weight and 0 for extra credit
1575
1596
            //Flip from the default of 0 to 1 (or vice versa) if ALL items in the category are still set to the old default.
1576
 
            if ($params->aggregation==GRADE_AGGREGATE_WEIGHTED_MEAN || $params->aggregation==GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
 
1597
            if (self::aggregation_uses_aggregationcoef($params->aggregation)) {
1577
1598
                $sql = $defaultaggregationcoef = null;
1578
1599
 
1579
 
                if ($params->aggregation==GRADE_AGGREGATE_WEIGHTED_MEAN) {
 
1600
                if (!self::aggregation_uses_extracredit($params->aggregation)) {
1580
1601
                    //if all items in this category have aggregation coefficient of 0 we can change it to 1 ie evenly weighted
1581
1602
                    $sql = "select count(id) from {grade_items} where categoryid=:categoryid and aggregationcoef!=0";
1582
1603
                    $defaultaggregationcoef = 1;
1583
 
                } else if ($params->aggregation==GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
 
1604
                } else {
1584
1605
                    //if all items in this category have aggregation coefficient of 1 we can change it to 0 ie no extra credit
1585
1606
                    $sql = "select count(id) from {grade_items} where categoryid=:categoryid and aggregationcoef!=1";
1586
1607
                    $defaultaggregationcoef = 0;