Skip to content

Commit

Permalink
Merge branch 'wip-MDL-47543-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle

Conflicts:
	theme/bootstrapbase/less/moodle/grade.less
	theme/bootstrapbase/style/moodle.css
  • Loading branch information
danpoltawski committed Oct 8, 2014
2 parents da88acc + 9f1088d commit 6668936
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 149 deletions.
2 changes: 1 addition & 1 deletion grade/edit/tree/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
}
}

print_grade_page_head($courseid, 'settings', 'setup', get_string('setupgradeslayout', 'grades'));
print_grade_page_head($courseid, 'settings', 'setup', get_string('categoriesanditems', 'grades'));

// Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox');
Expand Down
54 changes: 1 addition & 53 deletions grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class grade_edit_tree {

public $uses_weight = false;

/** @var bool indicates if tree has categories with aggregation method other than Natural. */
protected $uses_non_natural = false;

public $table;

public $categories = array();
Expand All @@ -73,10 +70,6 @@ public function __construct($gtree, $moving=false, $gpr) {

$this->columns = array(grade_edit_tree_column::factory('name', array('deepest_level' => $this->deepest_level)));

if ($this->uses_non_natural) {
$this->columns[] = grade_edit_tree_column::factory('aggregation', array('flag' => true));
}

if ($this->uses_weight) {
$this->columns[] = grade_edit_tree_column::factory('weight', array('adv' => 'weight'));
}
Expand Down Expand Up @@ -120,7 +113,7 @@ public function build_html_tree($element, $totals, $parents, $level, &$row_count

$object = $element['object'];
$eid = $element['eid'];
$object->name = $this->gtree->get_element_header($element, true, true, false);
$object->name = $this->gtree->get_element_header($element, true, true, true, true);
$object->stripped_name = $this->gtree->get_element_header($element, false, false, false);

$is_category_item = false;
Expand Down Expand Up @@ -523,10 +516,6 @@ function get_deepest_level($element, $level=0, $deepest_level=1) {
$level++;
$coefstring = $element['object']->get_coefstring();
if ($element['type'] == 'category') {
if ($element['object']->aggregation != GRADE_AGGREGATE_SUM) {
$this->uses_non_natural = true;
}

if ($coefstring == 'aggregationcoefweight' || $coefstring == 'aggregationcoefextraweightsum' ||
$coefstring == 'aggregationcoefextraweight') {
$this->uses_weight = true;
Expand Down Expand Up @@ -680,47 +669,6 @@ public function get_item_cell($item, $params) {
}
}

/**
* Class grade_edit_tree_column_aggregation
*
* @package core_grades
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_edit_tree_column_aggregation extends grade_edit_tree_column {

public function __construct($params) {
parent::__construct('aggregation');
}

public function get_header_cell() {
global $OUTPUT;
$headercell = clone($this->headercell);
$headercell->text = get_string('aggregation', 'grades').$OUTPUT->help_icon('aggregation', 'grades');
return $headercell;
}

public function get_category_cell($category, $levelclass, $params) {
global $CFG, $OUTPUT;
if (empty($params['id'])) {
throw new Exception('Array key (id) missing from 3rd param of grade_edit_tree_column_aggregation::get_category_cell($category, $levelclass, $params)');
}

$options = grade_helper::get_aggregation_strings();
$aggregation = $options[$category->aggregation];

$categorycell = parent::get_category_cell($category, $levelclass, $params);
$categorycell->text = $aggregation;
return $categorycell;

}

public function get_item_cell($item, $params) {
$itemcell = parent::get_item_cell($item, $params);
$itemcell->text = ' - ';
return $itemcell;
}
}

/**
* Class grade_edit_tree_column_weight
*
Expand Down
72 changes: 29 additions & 43 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
$plugin_info['report'] = $reports;
}

if ($settings = grade_helper::get_info_manage_settings($courseid)) {
$plugin_info['settings'] = $settings;
}

if ($scale = grade_helper::get_info_scales($courseid)) {
$plugin_info['scale'] = array('view'=>$scale);
}
Expand Down Expand Up @@ -685,16 +689,6 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
}
}

// Hide course settings if we're not in a course
if ($settings = grade_helper::get_info_manage_settings($courseid)) {
$plugin_info['settings'] = $settings;
}

// Put preferences last
if ($preferences = grade_helper::get_plugins_report_preferences($courseid)) {
$plugin_info['preferences'] = $preferences;
}

foreach ($plugin_info as $plugin_type => $plugins) {
if (!empty($plugins->id) && $active_plugin == $plugins->id) {
$plugin_info['strings']['active_plugin_str'] = $plugins->string;
Expand Down Expand Up @@ -790,6 +784,11 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
$buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null) {
global $CFG, $OUTPUT, $PAGE;

if ($active_type === 'preferences') {
// In Moodle 2.8 report preferences were moved under 'settings'. Allow backward compatibility for 3rd party grade reports.
$active_type = 'settings';
}

$plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin);

// Determine the string of the active plugin
Expand Down Expand Up @@ -2416,6 +2415,13 @@ function grade_extend_settings($plugininfo, $courseid) {
}
}

if ($settings = grade_helper::get_info_manage_settings($courseid)) {
$settingsnode = $gradenode->add($strings['settings'], null, navigation_node::TYPE_CONTAINER);
foreach ($settings as $setting) {
$settingsnode->add($setting->string, $setting->link, navigation_node::TYPE_SETTING, null, $setting->id, new pix_icon('i/settings', ''));
}
}

if ($imports = grade_helper::get_plugins_import($courseid)) {
$importnode = $gradenode->add($strings['import'], null, navigation_node::TYPE_CONTAINER);
foreach ($imports as $import) {
Expand All @@ -2430,20 +2436,6 @@ function grade_extend_settings($plugininfo, $courseid) {
}
}

if ($settings = grade_helper::get_info_manage_settings($courseid)) {
$settingsnode = $gradenode->add($strings['settings'], null, navigation_node::TYPE_CONTAINER);
foreach ($settings as $setting) {
$settingsnode->add($setting->string, $setting->link, navigation_node::TYPE_SETTING, null, $setting->id, new pix_icon('i/settings', ''));
}
}

if ($preferences = grade_helper::get_plugins_report_preferences($courseid)) {
$preferencesnode = $gradenode->add(get_string('myreportpreferences', 'grades'), null, navigation_node::TYPE_CONTAINER);
foreach ($preferences as $preference) {
$preferencesnode->add($preference->string, $preference->link, navigation_node::TYPE_SETTING, null, $preference->id, new pix_icon('i/settings', ''));
}
}

if ($letters = grade_helper::get_info_letters($courseid)) {
$letters = array_shift($letters);
$gradenode->add($strings['letter'], $letters->link, navigation_node::TYPE_SETTING, null, $letters->id, new pix_icon('i/settings', ''));
Expand Down Expand Up @@ -2556,8 +2548,7 @@ public static function get_plugin_strings() {
'letter' => get_string('letters', 'grades'),
'export' => get_string('export', 'grades'),
'import' => get_string('import'),
'preferences' => get_string('mypreferences', 'grades'),
'settings' => get_string('settings')
'settings' => get_string('edittree', 'grades')
);
}
return self::$pluginstrings;
Expand Down Expand Up @@ -2598,12 +2589,18 @@ public static function get_info_manage_settings($courseid) {
$context = context_course::instance($courseid);
self::$managesetting = array();
if ($courseid != SITEID && has_capability('moodle/grade:manage', $context)) {
self::$managesetting['categoriesanditems'] = new grade_plugin_info('setup',
new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid)),
get_string('categoriesanditems', 'grades'));
self::$managesetting['coursesettings'] = new grade_plugin_info('coursesettings',
new moodle_url('/grade/edit/settings/index.php', array('id'=>$courseid)),
get_string('coursegradesettings', 'grades'));
self::$managesetting['setup'] = new grade_plugin_info('setup',
new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid)),
get_string('setupgradeslayout', 'grades'));
}
if (self::$gradereportpreferences === null) {
self::get_plugins_reports($courseid);
}
if (self::$gradereportpreferences) {
self::$managesetting = array_merge(self::$managesetting, self::$gradereportpreferences);
}
return self::$managesetting;
}
Expand Down Expand Up @@ -2640,7 +2637,8 @@ public static function get_plugins_reports($courseid) {
// Add link to preferences tab if such a page exists
if (file_exists($plugindir.'/preferences.php')) {
$url = new moodle_url('/grade/report/'.$plugin.'/preferences.php', array('id'=>$courseid));
$gradepreferences[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr);
$gradepreferences[$plugin] = new grade_plugin_info($plugin, $url,
get_string('mypreferences', 'grades') . ': ' . $pluginstr);
}
}
if (count($gradereports) == 0) {
Expand All @@ -2657,19 +2655,7 @@ public static function get_plugins_reports($courseid) {
self::$gradereportpreferences = $gradepreferences;
return self::$gradereports;
}
/**
* Returns an array of grade plugin report preferences for plugin reports that
* support preferences
* @param int $courseid
* @return array
*/
public static function get_plugins_report_preferences($courseid) {
if (self::$gradereportpreferences !== null) {
return self::$gradereportpreferences;
}
self::get_plugins_reports($courseid);
return self::$gradereportpreferences;
}

/**
* Get information on scales
* @param int $courseid
Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
}

print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader'));
print_grade_page_head($courseid, 'settings', 'grader', get_string('preferences', 'gradereport_grader'));

// If USER has admin capability, print a link to the site config page for this report
if (has_capability('moodle/site:config', $systemcontext)) {
Expand Down
30 changes: 15 additions & 15 deletions grade/tests/behat/grade_aggregation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Feature: We can use calculated grade totals
| Hidden | 1 |
And I set the following settings for grade item "Test assignment eight":
| Hidden | 1 |
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Grade display type" to "Real (percentage)"
And I press "Save changes"

Expand All @@ -73,7 +73,7 @@ Feature: We can use calculated grade totals
| Exclude empty grades | 0 |
And I turn editing mode off
Then I should see "30.00 (30.00 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -98,7 +98,7 @@ Feature: We can use calculated grade totals
| Item weight | 3 |
And I turn editing mode off
Then I should see "27.14 (27.14 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -121,7 +121,7 @@ Feature: We can use calculated grade totals
| Extra credit | 1 |
And I turn editing mode off
Then I should see "45.19 (45.19 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -144,7 +144,7 @@ Feature: We can use calculated grade totals
| Extra credit weight | 2 |
And I turn editing mode off
Then I should see "42.50 (42.50 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -165,7 +165,7 @@ Feature: We can use calculated grade totals
| Exclude empty grades | 0 |
And I turn editing mode off
Then I should see "26.67 (26.67 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -190,7 +190,7 @@ Feature: We can use calculated grade totals
| Hidden | 1 |
And I turn editing mode off
Then I should see "0.00 (0.00 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -213,7 +213,7 @@ Feature: We can use calculated grade totals
| Hidden | 1 |
And I turn editing mode off
Then I should see "50.00 (50.00 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand All @@ -236,7 +236,7 @@ Feature: We can use calculated grade totals
| Hidden | 1 |
And I turn editing mode off
Then I should see "50.00 (50.00 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
And I press "Save changes"
And I log out
Expand Down Expand Up @@ -264,7 +264,7 @@ Feature: We can use calculated grade totals
| Extra credit | 1 |
And I turn editing mode off
Then I should see "152.68 (24.43 %)" in the ".course" "css_element"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I set the field "report_user_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I set the field "Show contribution to course total" to "Show"
Expand Down Expand Up @@ -317,7 +317,7 @@ Feature: We can use calculated grade totals
And I set the following settings for grade item "Course 1":
| Aggregation | Natural |
| Exclude empty grades | 0 |
And I navigate to "Set up grades layout" node in "Grade administration > Settings"
And I navigate to "Categories and items" node in "Grade administration > Setup"
And I press "Add category"
And I click on "Show more" "link"
And I set the following fields to these values:
Expand Down Expand Up @@ -372,7 +372,7 @@ Feature: We can use calculated grade totals
And I press "Save changes"
And I turn editing mode off
And I should see "250.00 (25.25 %)" in the ".course" "css_element"
And I navigate to "Set up grades layout" node in "Grade administration > Settings"
And I navigate to "Categories and items" node in "Grade administration > Setup"
And I press "Add category"
And I set the following fields to these values:
| Category name | Sub sub category 1 |
Expand All @@ -383,7 +383,7 @@ Feature: We can use calculated grade totals

@javascript
Scenario: Natural aggregation from the setup screen
And I set the field "Grade report" to "Set up grades layout"
And I set the field "Grade report" to "Categories and items"
And I follow "Edit Course 1"
And I set the field "Aggregation" to "Natural"
And I press "Save changes"
Expand Down Expand Up @@ -448,15 +448,15 @@ Feature: We can use calculated grade totals
| Aggregation | Natural |
| Exclude empty grades | 0 |
And I turn editing mode off
And I set the field "Grade report" to "Set up grades layout"
And I set the field "Grade report" to "Categories and items"
And I set the field "Override weight of Test assignment one" to "1"
And I set the field "Weight of Test assignment one" to "0"
And I set the field "Override weight of Test assignment six" to "1"
And I set the field "Weight of Test assignment six" to "0"
And I set the field "Override weight of Test assignment nine" to "1"
And I set the field "Weight of Test assignment nine" to "100"
And I press "Save changes"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I set the field "report_user_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I set the field "Show contribution to course total" to "Show"
Expand Down
Loading

0 comments on commit 6668936

Please sign in to comment.