MDL-47146 core_grades: merge simple and full view in setup

Part of: MDL-46576
This commit is contained in:
Marina Glancy 2014-09-16 11:48:22 +08:00 committed by Adrian Greeve
parent ddb9c95f1f
commit 8faa560ca9
13 changed files with 75 additions and 131 deletions

View File

@ -45,8 +45,6 @@ $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'settings', 'cour
$strgrades = get_string('grades');
$pagename = get_string('coursesettings', 'grades');
$navigation = grade_build_nav(__FILE__, $pagename, $courseid);
$returnurl = $CFG->wwwroot.'/grade/index.php?id='.$course->id;
$mform = new course_settings_form();
@ -76,7 +74,7 @@ if ($mform->is_cancelled()) {
redirect($returnurl);
}
print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursesettings', 'grades'));
print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursegradesettings', 'grades'));
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal centerpara');
echo get_string('coursesettingsexplanation', 'grades');

View File

@ -232,7 +232,7 @@ if ($mform->is_cancelled()) {
$return = false;
$buttons = false;
$shownavigation = false;
print_grade_page_head($courseid, 'edittree', null, $heading, $return, $buttons, $shownavigation);
print_grade_page_head($courseid, 'settings', null, $heading, $return, $buttons, $shownavigation);
$mform->display();

View File

@ -62,8 +62,6 @@ if (!isset($USER->gradeediting)) {
$USER->gradeediting = array();
}
$current_view = '';
if (has_capability('moodle/grade:manage', $context)) {
if (!isset($USER->gradeediting[$course->id])) {
$USER->gradeediting[$course->id] = 0;
@ -81,10 +79,8 @@ if (has_capability('moodle/grade:manage', $context)) {
if ($USER->gradeediting[$course->id]) {
$options['showadvanced'] = 0;
$current_view = 'fullview';
} else {
$options['showadvanced'] = 1;
$current_view = 'simpleview';
}
} else {
@ -128,8 +124,6 @@ $switch = grade_get_setting($course->id, 'aggregationposition', $CFG->grade_aggr
$strgrades = get_string('grades');
$strgraderreport = get_string('graderreport', 'grades');
$strcategoriesedit = get_string('categoriesedit', 'grades');
$strcategoriesanditems = get_string('categoriesanditems', 'grades');
$moving = false;
$movingeid = false;
@ -212,15 +206,6 @@ if ($grade_edit_tree->moving) {
$USER->gradeediting[$course->id] = 0;
}
$current_view_str = '';
if ($current_view != '') {
if ($current_view == 'simpleview') {
$current_view_str = get_string('simpleview', 'grades');
} elseif ($current_view == 'fullview') {
$current_view_str = get_string('fullview', 'grades');
}
}
//if we go straight to the db to update an element we need to recreate the tree as
// $grade_edit_tree has already been constructed.
//Ideally we could do the updates through $grade_edit_tree to avoid recreating it
@ -324,7 +309,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
grade_regrade_final_grades($courseid);
}
print_grade_page_head($courseid, 'edittree', $current_view, get_string('categoriesedit', 'grades') . ': ' . $current_view_str);
print_grade_page_head($courseid, 'settings', 'setup', get_string('setupgradeslayout', 'grades'));
// Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox');

View File

@ -183,7 +183,7 @@ if ($mform->is_cancelled()) {
$return = false;
$buttons = false;
$shownavigation = false;
print_grade_page_head($courseid, 'edittree', null, $heading, $return, $buttons, $shownavigation);
print_grade_page_head($courseid, 'settings', null, $heading, $return, $buttons, $shownavigation);
$mform->display();

View File

@ -214,7 +214,7 @@ if ($data = $mform->get_data()) {
redirect($returnurl);
}
print_grade_page_head($courseid, 'edittree', null, $heading);
print_grade_page_head($courseid, 'settings', null, $heading);
if (!grade_outcome::fetch_all_available($COURSE->id)) {
echo $OUTPUT->confirm(get_string('nooutcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$courseid, $returnurl);

View File

@ -609,13 +609,6 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
$plugin_info['report'] = $reports;
}
//showing grade categories and items make no sense if we're not within a course
if ($courseid!=$SITE->id) {
if ($edittree = grade_helper::get_info_edit_structure($courseid)) {
$plugin_info['edittree'] = $edittree;
}
}
if ($scale = grade_helper::get_info_scales($courseid)) {
$plugin_info['scale'] = array('view'=>$scale);
}
@ -650,11 +643,9 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
}
}
//hide course settings if we're not in a course
if ($courseid!=$SITE->id) {
if ($setting = grade_helper::get_info_manage_settings($courseid)) {
$plugin_info['settings'] = array('course'=>$setting);
}
// 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
@ -2382,8 +2373,11 @@ function grade_extend_settings($plugininfo, $courseid) {
}
}
if ($setting = grade_helper::get_info_manage_settings($courseid)) {
$gradenode->add(get_string('coursegradesettings', 'grades'), $setting->link, navigation_node::TYPE_SETTING, null, $setting->id, new pix_icon('i/settings', ''));
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)) {
@ -2407,13 +2401,6 @@ function grade_extend_settings($plugininfo, $courseid) {
$gradenode->add($strings['scale'], $scales->link, navigation_node::TYPE_SETTING, null, $scales->id, new pix_icon('i/scales', ''));
}
if ($categories = grade_helper::get_info_edit_structure($courseid)) {
$categoriesnode = $gradenode->add(get_string('categoriesanditems','grades'), null, navigation_node::TYPE_CONTAINER);
foreach ($categories as $category) {
$categoriesnode->add($category->string, $category->link, navigation_node::TYPE_SETTING, null, $category->id, new pix_icon('i/report', ''));
}
}
if ($gradenode->contains_active_node()) {
// If the gradenode is active include the settings base node (gradeadministration) in
// the navbar, typcially this is ignored.
@ -2463,11 +2450,6 @@ abstract class grade_helper {
* @var grade_plugin_info|false
*/
protected static $outcomeinfo = null;
/**
* Cached info on edit structure {@see get_info_edit_structure}
* @var array|false
*/
protected static $edittree = null;
/**
* Cached leftter info {@see get_info_letters}
* @var grade_plugin_info|false
@ -2498,7 +2480,6 @@ abstract class grade_helper {
* Gets strings commonly used by the describe plugins
*
* report => get_string('view'),
* edittree => get_string('edittree', 'grades'),
* scale => get_string('scales'),
* outcome => get_string('outcomes', 'grades'),
* letter => get_string('letters', 'grades'),
@ -2513,7 +2494,6 @@ abstract class grade_helper {
if (self::$pluginstrings === null) {
self::$pluginstrings = array(
'report' => get_string('view'),
'edittree' => get_string('edittree', 'grades'),
'scale' => get_string('scales'),
'outcome' => get_string('outcomes', 'grades'),
'letter' => get_string('letters', 'grades'),
@ -2552,17 +2532,21 @@ abstract class grade_helper {
* Get grade_plugin_info object for managing settings if the user can
*
* @param int $courseid
* @return grade_plugin_info
* @return grade_plugin_info[]
*/
public static function get_info_manage_settings($courseid) {
if (self::$managesetting !== null) {
return self::$managesetting;
}
$context = context_course::instance($courseid);
if (has_capability('moodle/grade:manage', $context)) {
self::$managesetting = new grade_plugin_info('coursesettings', new moodle_url('/grade/edit/settings/index.php', array('id'=>$courseid)), get_string('course'));
} else {
self::$managesetting = false;
self::$managesetting = array();
if ($courseid != SITEID && has_capability('moodle/grade:manage', $context)) {
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'));
}
return self::$managesetting;
}
@ -2683,26 +2667,6 @@ abstract class grade_helper {
}
return self::$outcomeinfo;
}
/**
* Get information on editing structures
* @param int $courseid
* @return array
*/
public static function get_info_edit_structure($courseid) {
if (self::$edittree !== null) {
return self::$edittree;
}
if (has_capability('moodle/grade:manage', context_course::instance($courseid))) {
$url = new moodle_url('/grade/edit/tree/index.php', array('sesskey'=>sesskey(), 'showadvanced'=>'0', 'id'=>$courseid));
self::$edittree = array(
'simpleview' => new grade_plugin_info('simpleview', $url, get_string('simpleview', 'grades')),
'fullview' => new grade_plugin_info('fullview', new moodle_url($url, array('showadvanced'=>'1')), get_string('fullview', 'grades'))
);
} else {
self::$edittree = false;
}
return self::$edittree;
}
/**
* Get information on letters
* @param int $courseid

View File

@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I set the field "Grade display type" to "Real (percentage)"
And I press "Save changes"
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -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 follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
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
@ -281,23 +281,16 @@ Feature: We can use calculated grade totals
And I follow "Course 1"
And I follow "Grades"
And I turn editing mode on
And I follow "Edit Sub category 1"
And I set the field "Aggregation" to "Natural"
And I click on "Show more..." "link"
And I set the field "Exclude empty grades" to "0"
And I press "Save changes"
And I follow "Edit Sub category 2"
And I set the field "Aggregation" to "Natural"
And I click on "Show more..." "link"
And I set the field "Exclude empty grades" to "0"
And I press "Save changes"
And I follow "Edit Course 1"
And I set the field "Aggregation" to "Natural"
And I click on "Show more..." "link"
And I set the field "Exclude empty grades" to "0"
And I press "Save changes"
And I expand "Setup" node
And I follow "Simple view"
And I set the following settings for grade item "Sub category 1":
| Aggregation | Natural |
| Exclude empty grades | 0 |
And I set the following settings for grade item "Sub category 2":
| Aggregation | Natural |
| Exclude empty grades | 0 |
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 press "Add category"
And I click on "Show more" "link"
And I set the following fields to these values:
@ -320,8 +313,7 @@ Feature: We can use calculated grade totals
| Item name | Manual item 3 |
| Grade category | Sub category 3 |
And I press "Save changes"
And I follow "Grades"
And I turn editing mode on
And I follow "Grader report"
And I give the grade "60.00" to the user "Student 1" for the grade item "Manual item 1"
And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
And I give the grade "40.00" to the user "Student 1" for the grade item "Manual item 3"
@ -329,16 +321,14 @@ Feature: We can use calculated grade totals
And I turn editing mode off
Then I should see "250.00 (25.25 %)" in the ".course" "css_element"
And I turn editing mode on
And I follow "Edit Manual item 2"
And I set the field "Extra credit" to "1"
And I press "Save changes"
And I set the following settings for grade item "Manual item 2":
| Extra credit | 1 |
And I turn editing mode off
And I should see "270.00 (27.27 %)" in the ".course" "css_element"
And I turn editing mode on
And I follow "Edit Manual item 2"
And I set the field "Extra credit" to "0"
And I set the field "Maximum grade" to "200"
And I press "Save changes"
And I set the following settings for grade item "Manual item 2":
| Extra credit | 0 |
| Maximum grade | 200 |
And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
And I press "Save changes"
And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
@ -346,22 +336,20 @@ Feature: We can use calculated grade totals
And I turn editing mode off
And I should see "270.00 (22.69 %)" in the ".course" "css_element"
And I turn editing mode on
And I follow "Edit Manual item 2"
And I set the field "Extra credit" to "0"
And I set the field "Maximum grade" to "100"
And I press "Save changes"
And I set the following settings for grade item "Manual item 2":
| Extra credit | 0 |
| Maximum grade | 100 |
And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
And I press "Save changes"
And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
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 expand "Setup" node
And I follow "Simple view"
And I navigate to "Set up grades layout" node in "Grade administration > Settings"
And I press "Add category"
And I set the following fields to these values:
| Category name | Sub sub category 1 |
| Parent category | Sub category 3 |
And I press "Save changes"
And I follow "Grades"
And I follow "Grader report"
And I should see "270.00 (24.77 %)" in the ".course" "css_element"

View File

@ -39,11 +39,11 @@ Feature: We can understand the gradebook user report
And I give the grade "70.00" to the user "Student 1" for the grade item "Test assignment five"
And I give the grade "30.00" to the user "Student 1" for the grade item "Test assignment six"
And I press "Save changes"
And I follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I set the field "Show weightings" to "Show"
And I set the field "Show contribution to course total" to "Show"
And I press "Save changes"
And I set the field "Grade report" to "Simple view"
And I set the field "Grade report" to "Set up grades layout"
And I press "Add category"
And I set the field "Category name" to "Sub category"
And I press "Save changes"

View File

@ -82,13 +82,13 @@ Feature: We can enter in grades and view reports from the gradebook
@javascript
Scenario: We can add a weighting to a grade item and it is displayed properly in the user report
When I set the field "Grade report" to "Full view"
When I set the field "Grade report" to "Set up grades layout"
And I set the following settings for grade item "Course 1":
| Aggregation | Weighted mean of grades |
And I set the field "Extra credit value for Test assignment name" to "0.72"
And I press "Save changes"
And I set the field "Grade report" to "User report"
And I follow "Course grade settings"
And I navigate to "Course grade settings" node in "Grade administration > Settings"
And I set the following fields to these values:
| Show weightings | Show |
And I press "Save changes"

View File

@ -4,3 +4,8 @@ hidden,core_portfolio
hidden,core_question
hidden,core_repository
hidden,core_role
categoriesanditems,core_grades
simpleview,core_grades
fullview,core_grades
categoriesedit,core_grades
edittree,core_grades

View File

@ -111,8 +111,6 @@ $string['calculationsaved'] = 'Calculation saved';
$string['calculationview'] = 'View calculation';
$string['cannotaccessgroup'] = 'Can not access grades of selected group, sorry.';
$string['categories'] = 'Categories';
$string['categoriesanditems'] = 'Setup';
$string['categoriesedit'] = 'Edit setup';
$string['category'] = 'Category';
$string['categoryedit'] = 'Edit category';
$string['categoryname'] = 'Category name';
@ -170,7 +168,6 @@ $string['editgradeletters'] = 'Edit grade letters';
$string['editoutcome'] = 'Edit outcome';
$string['editoutcomes'] = 'Edit outcomes';
$string['editscale'] = 'Edit scale';
$string['edittree'] = 'Setup';
$string['editverbose'] = 'Edit {$a->category} {$a->itemmodule} {$a->itemname}';
$string['enableajax'] = 'Enable AJAX';
$string['enableajax_help'] = 'Adds a layer of AJAX functionality to the grader report, simplifying and speeding up common operations. Depends on Javascript being switched on at the user\'s browser level.';
@ -226,7 +223,6 @@ $string['forelementtypes'] = 'for the selected {$a}';
$string['forstudents'] = 'For students';
$string['full'] = 'Full';
$string['fullmode'] = 'Full view';
$string['fullview'] = 'Full view';
$string['generalsettings'] = 'General settings';
$string['grade'] = 'Grade';
$string['gradeadministration'] = 'Grade administration';
@ -591,6 +587,7 @@ $string['setgradeletters'] = 'Set grade letters';
$string['setpreferences'] = 'Set preferences';
$string['setting'] = 'Setting';
$string['settings'] = 'Settings';
$string['setupgradeslayout'] = 'Set up grades layout';
$string['setweights'] = 'Set weights';
$string['showanalysisicon'] = 'Show grade analysis icon';
$string['showanalysisicon_desc'] = 'Whether to show grade analysis icon by default. If the activity module supports it, the grade analysis icon links to a page with more detailed explanation of the grade and how it was obtained.';
@ -650,7 +647,6 @@ $string['showrank_help'] = 'Show the position of the student in relation to the
$string['showuserimage'] = 'Show user profile images';
$string['showuserimage_help'] = 'Whether to show the user\'s profile image next to the name in the grader report.';
$string['showverbose'] = 'Show {$a->category} {$a->itemmodule} {$a->itemname}';
$string['simpleview'] = 'Simple view';
$string['sitewide'] = 'Site-wide';
$string['sort'] = 'sort';
$string['sortasc'] = 'Sort in ascending order';
@ -730,3 +726,11 @@ $string['writinggradebookinfo'] = 'Writing gradebook settings';
$string['xml'] = 'XML';
$string['yes'] = 'Yes';
$string['yourgrade'] = 'Your grade';
// Deprecated since Moodle 2.8
$string['categoriesanditems'] = 'Setup';
$string['categoriesedit'] = 'Edit setup';
$string['edittree'] = 'Setup';
$string['fullview'] = 'Full view';
$string['simpleview'] = 'Simple view';

View File

@ -49,12 +49,12 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
| Feedback for the response 'False'. | So you think it is false |
And I follow "Course 1"
And I follow "Grades"
And I follow "Simple view"
And I navigate to "Set up grades layout" node in "Grade administration > Settings"
And I follow "Edit quiz Test quiz name"
Then I should see "Edit grade item"
And I set the field "gradepass" to "5"
And I press "Save changes"
And I should see "Simple view"
And I should see "Set up grades layout"
Then I log out
And I log in as "student1"

View File

@ -48,13 +48,13 @@ Feature: Set a quiz to be marked complete when the student passes
| Feedback for the response 'False'. | So you think it is false |
And I follow "Course 1"
And I follow "Grades"
And I set the field "jump" to "Simple view"
And I set the field "jump" to "Set up grades layout"
And I press "Go"
And I follow "Edit quiz Test quiz name"
Then I should see "Edit grade item"
And I set the field "gradepass" to "5"
And I press "Save changes"
Then I should see "Simple view"
Then I should see "Set up grades layout"
And I log out
And I log in as "student1"