Skip to content

Commit

Permalink
merged fix for MDL-9185
Browse files Browse the repository at this point in the history
  • Loading branch information
toyomoyo committed Apr 4, 2007
1 parent 11cc8e6 commit 2d7617c
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 9 deletions.
28 changes: 25 additions & 3 deletions grade/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

require_login($course->id);

/*
if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
$group = get_and_set_current_group($course, $course->groupmode, $group);
} else {
$group = get_current_group($course->id);
}

*/

// if the user set new prefs make sure they happen now
if ($action == 'set_grade_preferences' && $prefs = data_submitted()) {
if (!confirm_sesskey()) {
Expand Down Expand Up @@ -49,9 +50,30 @@
}

print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));

grade_preferences_menu($action, $course, $group);

/// copied code from assignment module, if this is not the way to do this please change it
/// the above code does not work
/// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
/// and function groups_instance_print_group_selector() are missing.
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$groupmode = groupmode($course);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);

/// Now we need a menu for separategroups as well!
if ($groupmode == VISIBLEGROUPS || ($groupmode
&& has_capability('moodle/site:accessallgroups', $context))) {

//the following query really needs to change
if ($groups = groups_get_groups_names($course->id)) { //TODO:
print_box_start('groupmenu');
print_group_menu($groups, $groupmode, $currentgroup, 'index.php?id='.$course->id);
print_box_end(); // groupmenu
}
}

grade_set_uncategorized();

if (has_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $course->id))) {
Expand Down
28 changes: 26 additions & 2 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,14 +995,38 @@ function display_submissions() {
add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->assignment->id, $this->assignment->id, $this->cm->id);

print_header_simple(format_string($this->assignment->name,true), "", '<a href="index.php?id='.$course->id.'">'.$this->strassignments.'</a> -> <a href="view.php?a='.$this->assignment->id.'">'.format_string($this->assignment->name,true).'</a> -> '. $this->strsubmissions, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));

///Position swapped
/*
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = setup_and_print_groups($course, $groupmode, 'submissions.php?id='.$this->cm->id);
} else {
$currentgroup = false;
}

*/

/// copied code from assignment module, if this is not the way to do this please change it
/// the above code does not work
/// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
/// and function groups_instance_print_group_selector() are missing.

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$groupmode = groupmode($course, $cm);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);

/// Now we need a menu for separategroups as well!
if ($groupmode == VISIBLEGROUPS || ($groupmode
&& has_capability('moodle/site:accessallgroups', $context))) {

//the following query really needs to change
if ($groups = groups_get_groups_names($course->id)) { //TODO:
print_box_start('groupmenu');
print_group_menu($groups, $groupmode, $currentgroup, 'submissions.php?id='.$this->cm->id);
print_box_end(); // groupmenu
}
}

/// Get all teachers and students
if ($currentgroup) {
$users = get_group_users($currentgroup);
Expand Down
29 changes: 26 additions & 3 deletions mod/quiz/report/overview/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function display($quiz, $cm, $course) {
}
}

/*
// Check to see if groups are being used in this quiz
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
if (!$download) {
Expand All @@ -79,6 +80,29 @@ function display($quiz, $cm, $course) {
} else {
$currentgroup = false;
}
*/

/// copied code from assignment module, if this is not the way to do this please change it
/// the above code does not work
/// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
/// and function groups_instance_print_group_selector() are missing.

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$groupmode = groupmode($course, $cm);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);

/// Now we need a menu for separategroups as well!
if ($groupmode == VISIBLEGROUPS || ($groupmode
&& has_capability('moodle/site:accessallgroups', $context))) {

//the following query really needs to change
if ($groups = groups_get_groups_names($course->id)) { //TODO:
print_box_start('groupmenu');
print_group_menu($groups, $groupmode, $currentgroup, "report.php?id=$cm->id&amp;mode=overview");
print_box_end(); // groupmenu
}
}

// Set table options
$noattempts = optional_param('noattempts', 0, PARAM_INT);
Expand Down Expand Up @@ -300,8 +324,7 @@ function display($quiz, $cm, $course) {
$from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'role_assignments ra ON ra.userid = u.id '.
groups_members_join_sql().
'JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE ra.contextid ' . $contextlists . ' AND '. groups_members_where_sql($currentgroup) .' AND qa.preview = 0';

$where = ' WHERE ra.contextid ' . $contextlists . ' AND '. groups_members_where_sql($currentgroup) .' AND qa.preview = 0';
} else if (!empty($currentgroup) && !empty($noattempts)) {
// We want a particular group and we want to do something funky with attempts
// So join on groups_members and left join on attempts...
Expand Down Expand Up @@ -403,7 +426,7 @@ function display($quiz, $cm, $course) {
if (!empty($from)) { // if we're in the site course and displaying no attempts, it makes no sense to do the query.
if (!$download) {
$attempts = get_records_sql($select.$from.$where.$sort,
$table->get_page_start(), $table->get_page_size());
$table->get_page_start(), $table->get_page_size());
} else {
$attempts = get_records_sql($select.$from.$where.$sort);
}
Expand Down
26 changes: 25 additions & 1 deletion mod/workshop/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,33 @@
}

/// Check to see if groups are being used in this workshop
/*
setup_and_print_groups($course, groupmode($course, $cm), "view.php?id=$cm->id");
$currentgroup = get_current_group($course->id);

*/

/// copied code from assignment module, if this is not the way to do this please change it
/// the above code does not work
/// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
/// and function groups_instance_print_group_selector() are missing.

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$groupmode = groupmode($course, $cm);
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);

/// Now we need a menu for separategroups as well!
if ($groupmode == VISIBLEGROUPS || ($groupmode
&& has_capability('moodle/site:accessallgroups', $context))) {

//the following query really needs to change
if ($groups = groups_get_groups_names($course->id)) { //TODO:
print_box_start('groupmenu');
print_group_menu($groups, $groupmode, $currentgroup, "view.php?id=$cm->id");
print_box_end(); // groupmenu
}
}

/// Print admin links
echo "<table width=\"100%\"><tr><td>";
echo "<a href=\"submissions.php?id=$cm->id&amp;action=adminlist\">".
Expand Down

0 comments on commit 2d7617c

Please sign in to comment.