first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,115 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Define all the backup steps that will be used by the backup_block_task
* @package block_activity_results
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Specialised restore task for the activity_results block
* (using execute_after_tasks for recoding of target activity)
*
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_activity_results_block_task extends restore_block_task {
/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
}
/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
}
/**
* Define the associated file areas
*/
public function get_fileareas() {
return array(); // No associated fileareas.
}
/**
* Define special handling of configdata.
*/
public function get_configdata_encoded_attributes() {
return array(); // No special handling of configdata.
}
/**
* This function, executed after all the tasks in the plan
* have been executed, will perform the recode of the
* target activity for the block. This must be done here
* and not in normal execution steps because the activity
* can be restored after the block.
*/
public function after_restore() {
global $DB;
// Get the blockid.
$blockid = $this->get_blockid();
if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
$config = $this->decode_configdata($configdata);
if (!empty($config->activityparentid)) {
// Get the mapping and replace it in config.
if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
$config->activityparent, $config->activityparentid)) {
// Update the parent module id (the id from mdl_quiz etc...)
$config->activityparentid = $mapping->newitemid;
// Get the grade_items record to update the activitygradeitemid.
$info = $DB->get_record('grade_items',
array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));
// Update the activitygradeitemid the id from the grade_items table.
$config->activitygradeitemid = $info->id;
// Encode and save the config.
$configdata = base64_encode(serialize($config));
$DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
}
}
}
}
/**
* Define the contents in the activity that must be
* processed by the link decoder
*/
public static function define_decode_contents() {
return array();
}
/**
* Define the decoding rules for links belonging
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
return array();
}
}
@@ -0,0 +1,735 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Classes to enforce the various access rules that can apply to a activity.
*
* @package block_activity_results
* @copyright 2009 Tim Hunt
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/grade/constants.php');
require_once($CFG->dirroot . '/course/lib.php');
define('B_ACTIVITYRESULTS_NAME_FORMAT_FULL', 1);
define('B_ACTIVITYRESULTS_NAME_FORMAT_ID', 2);
define('B_ACTIVITYRESULTS_NAME_FORMAT_ANON', 3);
define('B_ACTIVITYRESULTS_GRADE_FORMAT_PCT', 1);
define('B_ACTIVITYRESULTS_GRADE_FORMAT_FRA', 2);
define('B_ACTIVITYRESULTS_GRADE_FORMAT_ABS', 3);
define('B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE', 4);
/**
* Block activity_results class definition.
*
* This block can be added to a course page or a activity page to display of list of
* the best/worst students/groups in a particular activity.
*
* @package block_activity_results
* @copyright 2009 Tim Hunt
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_activity_results extends block_base {
/**
* Core function used to initialize the block.
*/
public function init() {
$this->title = get_string('pluginname', 'block_activity_results');
}
/**
* Allow the block to have a configuration page
*
* @return boolean
*/
public function has_config() {
return true;
}
/**
* Core function, specifies where the block can be used.
* @return array
*/
public function applicable_formats() {
return array('course-view' => true, 'mod' => true);
}
/**
* If this block belongs to a activity context, then return that activity's id.
* Otherwise, return 0.
* @return stdclass the activity record.
*/
public function get_owning_activity() {
global $DB;
// Set some defaults.
$result = new stdClass();
$result->id = 0;
if (empty($this->instance->parentcontextid)) {
return $result;
}
$parentcontext = context::instance_by_id($this->instance->parentcontextid);
if ($parentcontext->contextlevel != CONTEXT_MODULE) {
return $result;
}
$cm = get_coursemodule_from_id($this->page->cm->modname, $parentcontext->instanceid);
if (!$cm) {
return $result;
}
// Get the grade_items id.
$rec = $DB->get_record('grade_items', array('iteminstance' => $cm->instance, 'itemmodule' => $this->page->cm->modname));
if (!$rec) {
return $result;
}
// See if it is a gradable activity.
if (($rec->gradetype != GRADE_TYPE_VALUE) && ($rec->gradetype != GRADE_TYPE_SCALE)) {
return $result;
}
return $rec;
}
/**
* Used to save the form config data
* @param stdclass $data
* @param bool $nolongerused
*/
public function instance_config_save($data, $nolongerused = false) {
global $DB;
if (empty($data->activitygradeitemid)) {
// Figure out info about parent module.
$info = $this->get_owning_activity();
$data->activitygradeitemid = $info->id;
if ($info->id < 1) {
// No activity was selected.
$info->itemmodule = '';
$info->iteminstance = '';
} else {
$data->activityparent = $info->itemmodule;
$data->activityparentid = $info->iteminstance;
}
} else {
// Lookup info about the parent module (we have the id from mdl_grade_items.
$info = $DB->get_record('grade_items', array('id' => $data->activitygradeitemid));
$data->activityparent = $info->itemmodule;
$data->activityparentid = $info->iteminstance;
}
parent::instance_config_save($data);
}
/**
* Used to generate the content for the block.
* @return string
*/
public function get_content() {
global $USER, $CFG, $DB;
if ($this->content !== null) {
return $this->content;
}
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
// We are configured so use the configuration.
if (!empty($this->config->activitygradeitemid)) {
// We are configured.
$activitygradeitemid = $this->config->activitygradeitemid;
// Lookup the module in the grade_items table.
$activity = $DB->get_record('grade_items', array('id' => $activitygradeitemid));
if (empty($activity)) {
// Activity does not exist.
$this->content->text = get_string('error_emptyactivityrecord', 'block_activity_results');
return $this->content;
}
$courseid = $activity->courseid;
$inactivity = false;
} else {
// Not configured.
$activitygradeitemid = 0;
}
// Check to see if we are in the moule we are displaying results for.
if (!empty($this->config->activitygradeitemid)) {
if ($this->get_owning_activity()->id == $this->config->activitygradeitemid) {
$inactivity = true;
} else {
$inactivity = false;
}
}
// Activity ID is missing.
if (empty($activitygradeitemid)) {
$this->content->text = get_string('error_emptyactivityid', 'block_activity_results');
return $this->content;
}
// Check to see if we are configured.
if (empty($this->config->showbest) && empty($this->config->showworst)) {
$this->content->text = get_string('configuredtoshownothing', 'block_activity_results');
return $this->content;
}
// Check to see if it is a supported grade type.
if (empty($activity->gradetype) || ($activity->gradetype != GRADE_TYPE_VALUE && $activity->gradetype != GRADE_TYPE_SCALE)) {
$this->content->text = get_string('error_unsupportedgradetype', 'block_activity_results');
return $this->content;
}
// Get the grades for this activity.
$sql = 'SELECT * FROM {grade_grades}
WHERE itemid = ? AND finalgrade is not NULL
ORDER BY finalgrade, timemodified DESC';
$grades = $DB->get_records_sql($sql, array( $activitygradeitemid));
if (empty($grades) || $activity->hidden) {
// No grades available, The block will hide itself in this case.
return $this->content;
}
// Set up results.
$groupmode = NOGROUPS;
$best = array();
$worst = array();
if (!empty($this->config->nameformat)) {
$nameformat = $this->config->nameformat;
} else {
$nameformat = B_ACTIVITYRESULTS_NAME_FORMAT_FULL;
}
// Get $cm and context.
if ($inactivity) {
$cm = $this->page->cm;
$context = $this->page->context;
} else {
$cm = get_coursemodule_from_instance($activity->itemmodule, $activity->iteminstance, $courseid);
$context = context_module::instance($cm->id);
}
if (!empty($this->config->usegroups)) {
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode == SEPARATEGROUPS && has_capability('moodle/site:accessallgroups', $context)) {
// If you have the ability to see all groups then lets show them.
$groupmode = VISIBLEGROUPS;
}
}
switch ($groupmode) {
case VISIBLEGROUPS:
// Display group-mode results.
$groups = groups_get_all_groups($courseid);
if (empty($groups)) {
// No groups exist, sorry.
$this->content->text = get_string('error_nogroupsexist', 'block_activity_results');
return $this->content;
}
// Find out all the userids which have a submitted grade.
$userids = array();
$gradeforuser = array();
foreach ($grades as $grade) {
$userids[] = $grade->userid;
$gradeforuser[$grade->userid] = (float)$grade->finalgrade;
}
// Now find which groups these users belong in.
list($usertest, $params) = $DB->get_in_or_equal($userids);
$params[] = $courseid;
$usergroups = $DB->get_records_sql('
SELECT gm.id, gm.userid, gm.groupid, g.name
FROM {groups} g
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
WHERE gm.userid ' . $usertest . ' AND g.courseid = ?', $params);
// Now, iterate the grades again and sum them up for each group.
$groupgrades = array();
foreach ($usergroups as $usergroup) {
if (!isset($groupgrades[$usergroup->groupid])) {
$groupgrades[$usergroup->groupid] = array(
'sum' => (float)$gradeforuser[$usergroup->userid],
'number' => 1,
'group' => $usergroup->name);
} else {
$groupgrades[$usergroup->groupid]['sum'] += $gradeforuser[$usergroup->userid];
$groupgrades[$usergroup->groupid]['number'] += 1;
}
}
foreach ($groupgrades as $groupid => $groupgrade) {
$groupgrades[$groupid]['average'] = $groupgrades[$groupid]['sum'] / $groupgrades[$groupid]['number'];
}
// Sort groupgrades according to average grade, ascending.
uasort($groupgrades, function($a, $b) {
if ($a["average"] == $b["average"]) {
return 0;
}
return ($a["average"] > $b["average"] ? 1 : -1);
});
// How many groups do we have with graded member submissions to show?
$numbest = empty($this->config->showbest) ? 0 : min($this->config->showbest, count($groupgrades));
$numworst = empty($this->config->showworst) ? 0 : min($this->config->showworst, count($groupgrades) - $numbest);
// Collect all the group results we are going to use in $best and $worst.
$remaining = $numbest;
$groupgrade = end($groupgrades);
while ($remaining--) {
$best[key($groupgrades)] = $groupgrade['average'];
$groupgrade = prev($groupgrades);
}
$remaining = $numworst;
$groupgrade = reset($groupgrades);
while ($remaining--) {
$worst[key($groupgrades)] = $groupgrade['average'];
$groupgrade = next($groupgrades);
}
// Ready for output!
if ($activity->gradetype == GRADE_TYPE_SCALE) {
// We must display the results using scales.
$gradeformat = B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE;
// Preload the scale.
$scale = $this->get_scale($activity->scaleid);
} else if (intval(empty($this->config->gradeformat))) {
$gradeformat = B_ACTIVITYRESULTS_GRADE_FORMAT_PCT;
} else {
$gradeformat = $this->config->gradeformat;
}
// Generate the header.
$this->content->text .= $this->activity_link($activity, $cm);
if ($nameformat == B_ACTIVITYRESULTS_NAME_FORMAT_FULL) {
if (has_capability('moodle/course:managegroups', $context)) {
$grouplink = $CFG->wwwroot.'/group/overview.php?id='.$courseid.'&amp;group=';
} else if (course_can_view_participants($context)) {
$grouplink = $CFG->wwwroot.'/user/index.php?id='.$courseid.'&amp;group=';
} else {
$grouplink = '';
}
}
$rank = 0;
if (!empty($best)) {
$this->content->text .= '<table class="grades"><caption class="pb-0"><h6>';
if ($numbest == 1) {
$this->content->text .= get_string('bestgroupgrade', 'block_activity_results');
} else {
$this->content->text .= get_string('bestgroupgrades', 'block_activity_results', $numbest);
}
$this->content->text .= '</h6></caption><colgroup class="number" />';
$this->content->text .= '<colgroup class="name" /><colgroup class="grade" /><tbody>';
foreach ($best as $groupid => $averagegrade) {
switch ($nameformat) {
case B_ACTIVITYRESULTS_NAME_FORMAT_ANON:
case B_ACTIVITYRESULTS_NAME_FORMAT_ID:
$thisname = get_string('group');
break;
default:
case B_ACTIVITYRESULTS_NAME_FORMAT_FULL:
if ($grouplink) {
$thisname = '<a href="'.$grouplink.$groupid.'">'.$groupgrades[$groupid]['group'].'</a>';
} else {
$thisname = $groupgrades[$groupid]['group'];
}
break;
}
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
switch ($gradeformat) {
case B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE:
// Round answer up and locate appropriate scale.
$answer = (round($averagegrade, 0, PHP_ROUND_HALF_UP) - 1);
if (isset($scale[$answer])) {
$this->content->text .= $scale[$answer];
} else {
// Value is not in the scale.
$this->content->text .= get_string('unknown', 'block_activity_results');
}
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_FRA:
$this->content->text .= $this->activity_format_grade($averagegrade)
. '/' . $this->activity_format_grade($activity->grademax);
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_ABS:
$this->content->text .= $this->activity_format_grade($averagegrade);
break;
default:
case B_ACTIVITYRESULTS_GRADE_FORMAT_PCT:
$this->content->text .= $this->activity_format_grade((float)$averagegrade /
(float)$activity->grademax * 100).'%';
break;
}
$this->content->text .= '</td></tr>';
}
$this->content->text .= '</tbody></table>';
}
$rank = 0;
if (!empty($worst)) {
$worst = array_reverse($worst, true);
$this->content->text .= '<table class="grades"><caption class="pb-0"><h6>';
if ($numworst == 1) {
$this->content->text .= get_string('worstgroupgrade', 'block_activity_results');
} else {
$this->content->text .= get_string('worstgroupgrades', 'block_activity_results', $numworst);
}
$this->content->text .= '</h6></caption><colgroup class="number" />';
$this->content->text .= '<colgroup class="name" /><colgroup class="grade" /><tbody>';
foreach ($worst as $groupid => $averagegrade) {
switch ($nameformat) {
case B_ACTIVITYRESULTS_NAME_FORMAT_ANON:
case B_ACTIVITYRESULTS_NAME_FORMAT_ID:
$thisname = get_string('group');
break;
default:
case B_ACTIVITYRESULTS_NAME_FORMAT_FULL:
if ($grouplink) {
$thisname = '<a href="'.$grouplink.$groupid.'">'.$groupgrades[$groupid]['group'].'</a>';
} else {
$thisname = $groupgrades[$groupid]['group'];
}
break;
}
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
switch ($gradeformat) {
case B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE:
// Round answer up and locate appropriate scale.
$answer = (round($averagegrade, 0, PHP_ROUND_HALF_UP) - 1);
if (isset($scale[$answer])) {
$this->content->text .= $scale[$answer];
} else {
// Value is not in the scale.
$this->content->text .= get_string('unknown', 'block_activity_results');
}
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_FRA:
$this->content->text .= $this->activity_format_grade($averagegrade)
. '/' . $this->activity_format_grade($activity->grademax);
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_ABS:
$this->content->text .= $this->activity_format_grade($averagegrade);
break;
default:
case B_ACTIVITYRESULTS_GRADE_FORMAT_PCT:
$this->content->text .= $this->activity_format_grade((float)$averagegrade /
(float)$activity->grademax * 100).'%';
break;
}
$this->content->text .= '</td></tr>';
}
$this->content->text .= '</tbody></table>';
}
break;
case SEPARATEGROUPS:
// This is going to be just like no-groups mode, only we 'll filter
// out the grades from people not in our group.
if (!isloggedin()) {
// Not logged in, so show nothing.
return $this->content;
}
$mygroups = groups_get_all_groups($courseid, $USER->id);
if (empty($mygroups)) {
// Not member of a group, show nothing.
return $this->content;
}
// Get users from the same groups as me.
list($grouptest, $params) = $DB->get_in_or_equal(array_keys($mygroups));
$mygroupsusers = $DB->get_records_sql_menu(
'SELECT DISTINCT userid, 1 FROM {groups_members} WHERE groupid ' . $grouptest,
$params);
// Filter out the grades belonging to other users, and proceed as if there were no groups.
foreach ($grades as $key => $grade) {
if (!isset($mygroupsusers[$grade->userid])) {
unset($grades[$key]);
}
}
// No break, fall through to the default case now we have filtered the $grades array.
default:
case NOGROUPS:
// Single user mode.
$numbest = empty($this->config->showbest) ? 0 : min($this->config->showbest, count($grades));
$numworst = empty($this->config->showworst) ? 0 : min($this->config->showworst, count($grades) - $numbest);
// Collect all the usernames we are going to need.
$remaining = $numbest;
$grade = end($grades);
while ($remaining--) {
$best[$grade->userid] = $grade->id;
$grade = prev($grades);
}
$remaining = $numworst;
$grade = reset($grades);
while ($remaining--) {
$worst[$grade->userid] = $grade->id;
$grade = next($grades);
}
if (empty($best) && empty($worst)) {
// Nothing to show, for some reason...
return $this->content;
}
// Now grab all the users from the database.
$userids = array_merge(array_keys($best), array_keys($worst));
$fields = array_merge(array('id', 'idnumber'), \core_user\fields::get_name_fields());
$fields = implode(',', $fields);
$users = $DB->get_records_list('user', 'id', $userids, '', $fields);
// If configured to view user idnumber, ensure current user can see it.
$extrafields = \core_user\fields::for_identity($this->context)->get_required_fields();
$canviewidnumber = (array_search('idnumber', $extrafields) !== false);
// Ready for output!
if ($activity->gradetype == GRADE_TYPE_SCALE) {
// We must display the results using scales.
$gradeformat = B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE;
// Preload the scale.
$scale = $this->get_scale($activity->scaleid);
} else if (intval(empty($this->config->gradeformat))) {
$gradeformat = B_ACTIVITYRESULTS_GRADE_FORMAT_PCT;
} else {
$gradeformat = $this->config->gradeformat;
}
// Generate the header.
$this->content->text .= $this->activity_link($activity, $cm);
$rank = 0;
if (!empty($best)) {
$this->content->text .= '<table class="grades"><caption class="pb-0"><h6>';
if ($numbest == 1) {
$this->content->text .= get_string('bestgrade', 'block_activity_results');
} else {
$this->content->text .= get_string('bestgrades', 'block_activity_results', $numbest);
}
$this->content->text .= '</h6></caption><colgroup class="number" />';
$this->content->text .= '<colgroup class="name" /><colgroup class="grade" /><tbody>';
foreach ($best as $userid => $gradeid) {
switch ($nameformat) {
case B_ACTIVITYRESULTS_NAME_FORMAT_ID:
$thisname = get_string('user');
if ($canviewidnumber) {
$thisname .= ' ' . s($users[$userid]->idnumber);
}
break;
case B_ACTIVITYRESULTS_NAME_FORMAT_ANON:
$thisname = get_string('user');
break;
default:
case B_ACTIVITYRESULTS_NAME_FORMAT_FULL:
if (has_capability('moodle/user:viewdetails', $context)) {
$thisname = html_writer::link(new moodle_url('/user/view.php',
array('id' => $userid, 'course' => $courseid)), fullname($users[$userid]));
} else {
$thisname = fullname($users[$userid]);
}
break;
}
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
switch ($gradeformat) {
case B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE:
// Round answer up and locate appropriate scale.
$answer = (round($grades[$gradeid]->finalgrade, 0, PHP_ROUND_HALF_UP) - 1);
if (isset($scale[$answer])) {
$this->content->text .= $scale[$answer];
} else {
// Value is not in the scale.
$this->content->text .= get_string('unknown', 'block_activity_results');
}
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_FRA:
$this->content->text .= $this->activity_format_grade($grades[$gradeid]->finalgrade);
$this->content->text .= '/'.$this->activity_format_grade($activity->grademax);
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_ABS:
$this->content->text .= $this->activity_format_grade($grades[$gradeid]->finalgrade);
break;
default:
case B_ACTIVITYRESULTS_GRADE_FORMAT_PCT:
if ($activity->grademax) {
$this->content->text .= $this->activity_format_grade((float)$grades[$gradeid]->finalgrade /
(float)$activity->grademax * 100).'%';
} else {
$this->content->text .= '--%';
}
break;
}
$this->content->text .= '</td></tr>';
}
$this->content->text .= '</tbody></table>';
}
$rank = 0;
if (!empty($worst)) {
$worst = array_reverse($worst, true);
$this->content->text .= '<table class="grades"><caption class="pb-0"><h6>';
if ($numbest == 1) {
$this->content->text .= get_string('worstgrade', 'block_activity_results');
} else {
$this->content->text .= get_string('worstgrades', 'block_activity_results', $numworst);
}
$this->content->text .= '</h6></caption><colgroup class="number" />';
$this->content->text .= '<colgroup class="name" /><colgroup class="grade" /><tbody>';
foreach ($worst as $userid => $gradeid) {
switch ($nameformat) {
case B_ACTIVITYRESULTS_NAME_FORMAT_ID:
$thisname = get_string('user');
if ($canviewidnumber) {
$thisname .= ' ' . s($users[$userid]->idnumber);
};
break;
case B_ACTIVITYRESULTS_NAME_FORMAT_ANON:
$thisname = get_string('user');
break;
default:
case B_ACTIVITYRESULTS_NAME_FORMAT_FULL:
if (has_capability('moodle/user:viewdetails', $context)) {
$thisname = html_writer::link(new moodle_url('/user/view.php',
array('id' => $userid, 'course' => $courseid)), fullname($users[$userid]));
} else {
$thisname = fullname($users[$userid]);
}
break;
}
$this->content->text .= '<tr><td>'.(++$rank).'.</td><td>'.$thisname.'</td><td>';
switch ($gradeformat) {
case B_ACTIVITYRESULTS_GRADE_FORMAT_SCALE:
// Round answer up and locate appropriate scale.
$answer = (round($grades[$gradeid]->finalgrade, 0, PHP_ROUND_HALF_UP) - 1);
if (isset($scale[$answer])) {
$this->content->text .= $scale[$answer];
} else {
// Value is not in the scale.
$this->content->text .= get_string('unknown', 'block_activity_results');
}
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_FRA:
$this->content->text .= $this->activity_format_grade($grades[$gradeid]->finalgrade);
$this->content->text .= '/'.$this->activity_format_grade($activity->grademax);
break;
case B_ACTIVITYRESULTS_GRADE_FORMAT_ABS:
$this->content->text .= $this->activity_format_grade($grades[$gradeid]->finalgrade);
break;
default:
case B_ACTIVITYRESULTS_GRADE_FORMAT_PCT:
if ($activity->grademax) {
$this->content->text .= $this->activity_format_grade((float)$grades[$gradeid]->finalgrade /
(float)$activity->grademax * 100).'%';
} else {
$this->content->text .= '--%';
}
break;
}
$this->content->text .= '</td></tr>';
}
$this->content->text .= '</tbody></table>';
}
break;
}
return $this->content;
}
/**
* Allows the block to be added multiple times to a single page
* @return boolean
*/
public function instance_allow_multiple() {
return true;
}
/**
* Formats the grade to the specified decimal points
* @param float $grade
* @return string
*/
private function activity_format_grade($grade) {
if (is_null($grade)) {
return get_string('notyetgraded', 'block_activity_results');
}
return format_float($grade, $this->config->decimalpoints);
}
/**
* Generates the Link to the activity module when displayed outside of the module.
* @param stdclass $activity
* @param stdclass $cm
* @return string
*/
private function activity_link($activity, $cm) {
$o = html_writer::start_tag('h5');
$o .= html_writer::link(new moodle_url('/mod/'.$activity->itemmodule.'/view.php',
array('id' => $cm->id)), format_string(($activity->itemname), true, ['context' => context_module::instance($cm->id)]));
$o .= html_writer::end_tag('h5');
return $o;
}
/**
* Generates a numeric array of scale entries
* @param int $scaleid
* @return array
*/
private function get_scale($scaleid) {
global $DB;
$scaletext = $DB->get_field('scale', 'scale', array('id' => $scaleid), IGNORE_MISSING);
$scale = explode ( ',', $scaletext);
return $scale;
}
/**
* Return the plugin config settings for external functions.
*
* @return stdClass the configs for both the block instance and plugin
* @since Moodle 3.8
*/
public function get_config_for_external() {
// Return all settings for all users since it is safe (no private keys, etc..).
$instanceconfigs = !empty($this->config) ? $this->config : new stdClass();
$pluginconfigs = get_config('block_activity_results');
return (object) [
'instance' => $instanceconfigs,
'plugin' => $pluginconfigs,
];
}
}
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for block_activity_results.
*
* @package block_activity_results
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_activity_results\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_activity_results implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Activity results block caps.
*
* @package block_activity_results
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/activity_results:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);
+136
View File
@@ -0,0 +1,136 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines the form for editing Quiz results block instances.
*
* @package block_activity_results
* @copyright 2009 Tim Hunt
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/grade/constants.php');
/**
* Form for editing activity results block instances.
*
* @copyright 2009 Tim Hunt
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_activity_results_edit_form extends block_edit_form {
/**
* The definition of the fields to use.
*
* @param MoodleQuickForm $mform
*/
protected function specific_definition($mform) {
global $DB;
// Load defaults.
$blockconfig = get_config('block_activity_results');
// Fields for editing activity_results block title and contents.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
// Get supported modules (Only modules using grades or scales will be listed).
$sql = 'SELECT id, itemname FROM {grade_items} WHERE courseid = ? and itemtype = ? and (gradetype = ? or gradetype = ?)';
$params = array($this->page->course->id, 'mod', GRADE_TYPE_VALUE, GRADE_TYPE_SCALE);
$activities = $DB->get_records_sql_menu($sql, $params);
core_collator::asort($activities);
if (empty($activities)) {
$mform->addElement('static', 'noactivitieswarning', get_string('config_select_activity', 'block_activity_results'),
get_string('config_no_activities_in_course', 'block_activity_results'));
} else {
foreach ($activities as $id => $name) {
$activities[$id] = strip_tags(format_string($name));
}
$mform->addElement('select', 'config_activitygradeitemid',
get_string('config_select_activity', 'block_activity_results'), $activities);
$mform->setDefault('config_activitygradeitemid', $this->block->get_owning_activity()->id);
}
$mform->addElement('text', 'config_showbest',
get_string('config_show_best', 'block_activity_results'), array('size' => 3));
$mform->setDefault('config_showbest', $blockconfig->config_showbest);
$mform->setType('config_showbest', PARAM_INT);
if ($blockconfig->config_showbest_locked) {
$mform->freeze('config_showbest');
}
$mform->addElement('text', 'config_showworst',
get_string('config_show_worst', 'block_activity_results'), array('size' => 3));
$mform->setDefault('config_showworst', $blockconfig->config_showworst);
$mform->setType('config_showworst', PARAM_INT);
if ($blockconfig->config_showworst_locked) {
$mform->freeze('config_showworst');
}
$mform->addElement('selectyesno', 'config_usegroups', get_string('config_use_groups', 'block_activity_results'));
$mform->setDefault('config_usegroups', $blockconfig->config_usegroups);
if ($blockconfig->config_usegroups_locked) {
$mform->freeze('config_usegroups');
}
$nameoptions = array(
B_ACTIVITYRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_activity_results'),
B_ACTIVITYRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_activity_results'),
B_ACTIVITYRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_activity_results')
);
$mform->addElement('select', 'config_nameformat',
get_string('config_name_format', 'block_activity_results'), $nameoptions);
$mform->setDefault('config_nameformat', $blockconfig->config_nameformat);
if ($blockconfig->config_nameformat_locked) {
$mform->freeze('config_nameformat');
}
$gradeeoptions = array(
B_ACTIVITYRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_activity_results'),
B_ACTIVITYRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_activity_results'),
B_ACTIVITYRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_activity_results')
);
$mform->addElement('select', 'config_gradeformat',
get_string('config_grade_format', 'block_activity_results'), $gradeeoptions);
$mform->setDefault('config_gradeformat', $blockconfig->config_gradeformat);
if ($blockconfig->config_gradeformat_locked) {
$mform->freeze('config_gradeformat');
}
$options = array();
for ($i = 0; $i <= 5; $i++) {
$options[$i] = $i;
}
$mform->addElement('select', 'config_decimalpoints', get_string('config_decimalplaces', 'block_activity_results'),
$options);
$mform->setDefault('config_decimalpoints', $blockconfig->config_decimalpoints);
$mform->setType('config_decimalpoints', PARAM_INT);
if ($blockconfig->config_decimalpoints_locked) {
$mform->freeze('config_decimalpoints');
}
}
/**
* Display the configuration form when block is being added to the page
*
* @return bool
*/
public static function display_form_when_adding(): bool {
return true;
}
}
@@ -0,0 +1,68 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'block_activity_results', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_activity_results
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['activity_results:addinstance'] = 'Add a new activity results block';
$string['bestgrade'] = 'The highest grade:';
$string['bestgrades'] = 'The {$a} highest grades:';
$string['bestgroupgrade'] = 'The group with the highest average:';
$string['bestgroupgrades'] = 'The {$a} groups with the highest average:';
$string['config_format_absolute'] = 'Absolute numbers';
$string['config_format_fraction'] = 'Fractions';
$string['config_format_percentage'] = 'Percentages';
$string['config_decimalplaces'] = 'Decimal places to display';
$string['config_grade_format'] = 'Display grades as';
$string['config_name_format'] = 'Privacy of results';
$string['config_names_anon'] = 'Anonymous results';
$string['config_names_full'] = 'Display full names';
$string['config_names_id'] = 'Display only ID numbers';
$string['config_no_activities_in_course'] = 'There are not yet any activities in this course.';
$string['config_select_activity'] = 'Which activity should this block display results from?';
$string['config_show_best'] = 'How many of the highest grades should be shown (0 to disable)?';
$string['config_show_worst'] = 'How many of the lowest grades should be shown (0 to disable)?';
$string['configuredtoshownothing'] = 'This block\'s configuration currently does not allow it to show any results.';
$string['config_use_groups'] = 'Show groups instead of students (only if the activity supports groups)?';
$string['defaulthighestgrades'] = 'Default highest grades shown';
$string['defaulthighestgrades_desc'] = 'How many of the highest grades should be shown by default?';
$string['defaultlowestgrades'] = 'Default lowest grades shown';
$string['defaultlowestgrades_desc'] = 'How many of the lowest grades should be shown by default?';
$string['defaultshowgroups'] = 'Default show groups';
$string['defaultnameoptions'] = 'Privacy of results';
$string['defaultnameoptions_desc'] = 'How should the students be identified by default?';
$string['defaultshowgroups_desc'] = 'Show groups instead of students by default (only if the activity supports groups)';
$string['defaultgradedisplay'] = 'Display grades as';
$string['defaultgradedisplay_desc'] = 'How should the grades be displayed by default?';
$string['defaultdecimalplaces'] = 'Decimal places';
$string['defaultdecimalplaces_desc'] = 'Number of decimal places to display by default';
$string['error_emptyactivityid'] = 'Please configure this block and select which activity it should display results from.';
$string['error_emptyactivityrecord'] = 'Error: the selected activity does not exist in the database.';
$string['error_nogroupsexist'] = 'Error: the block is set to display grades in group mode, but there are no groups defined.';
$string['error_unsupportedgradetype'] = 'Error: the activity selected uses a grading method that is not supported by this block.';
$string['notyetgraded'] = 'Not yet graded';
$string['pluginname'] = 'Activity results';
$string['unknown'] = 'Unknown scale';
$string['worstgrade'] = 'The lowest grade:';
$string['worstgrades'] = 'The {$a} lowest grades:';
$string['worstgroupgrade'] = 'The group with the lowest average:';
$string['worstgroupgrades'] = 'The {$a} groups with the lowest average:';
$string['privacy:metadata'] = 'The Activity results block only shows data stored in other locations.';
+86
View File
@@ -0,0 +1,86 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines the form for editing activity results block instances.
*
* @package block_activity_results
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
// Default high scores.
$setting = new admin_setting_configtext('block_activity_results/config_showbest',
new lang_string('defaulthighestgrades', 'block_activity_results'),
new lang_string('defaulthighestgrades_desc', 'block_activity_results'), 3, PARAM_INT);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
// Default low scores.
$setting = new admin_setting_configtext('block_activity_results/config_showworst',
new lang_string('defaultlowestgrades', 'block_activity_results'),
new lang_string('defaultlowestgrades_desc', 'block_activity_results'), 0, PARAM_INT);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
// Default group display.
$yesno = array(0 => get_string('no'), 1 => get_string('yes'));
$setting = new admin_setting_configselect('block_activity_results/config_usegroups',
new lang_string('defaultshowgroups', 'block_activity_results'),
new lang_string('defaultshowgroups_desc', 'block_activity_results'), 0, $yesno);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
// Default privacy settings.
$nameoptions = array(
B_ACTIVITYRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_activity_results'),
B_ACTIVITYRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_activity_results'),
B_ACTIVITYRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_activity_results')
);
$setting = new admin_setting_configselect('block_activity_results/config_nameformat',
new lang_string('defaultnameoptions', 'block_activity_results'),
new lang_string('defaultnameoptions_desc', 'block_activity_results'), B_ACTIVITYRESULTS_NAME_FORMAT_FULL, $nameoptions);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
// Default grade display settings.
$gradeoptions = array(
B_ACTIVITYRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_activity_results'),
B_ACTIVITYRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_activity_results'),
B_ACTIVITYRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_activity_results')
);
$setting = new admin_setting_configselect('block_activity_results/config_gradeformat',
new lang_string('defaultgradedisplay', 'block_activity_results'),
new lang_string('defaultgradedisplay_desc', 'block_activity_results'), B_ACTIVITYRESULTS_GRADE_FORMAT_PCT, $gradeoptions);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
// Default decimal places.
$places = array();
for ($i = 0; $i <= 5; $i++) {
$places[$i] = $i;
}
$setting = new admin_setting_configselect('block_activity_results/config_decimalpoints',
new lang_string('defaultdecimalplaces', 'block_activity_results'),
new lang_string('defaultdecimalplaces_desc', 'block_activity_results'), 2, $places);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
}
+23
View File
@@ -0,0 +1,23 @@
.block_activity_results h1 {
margin: 4px;
font-size: 1.1em;
}
.block_activity_results table.grades {
text-align: left;
width: 100%;
}
.block_activity_results table.grades .number {
text-align: left;
width: 10%;
}
.block_activity_results table.grades .name {
text-align: left;
width: 77%;
}
.block_activity_results table.grades .grade {
text-align: right;
}
@@ -0,0 +1,80 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | section | idnumber | assignsubmission_file_enabled |
| assign | Test assignment 1 | Offline text | C1 | 1 | assign1 | 0 |
| assign | Test assignment 2 | Offline text | C1 | 1 | assign2 | 0 |
| assign | Test assignment 3 | Offline text | C1 | 1 | assign3 | 0 |
And the following "activities" exist:
| activity | name | content | course | section | idnumber |
| page | Test page name | This is a page | C1 | 1 | page1 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment 1 | student1 | 90.00 |
| Test assignment 1 | student2 | 80.00 |
| Test assignment 1 | student3 | 70.00 |
| Test assignment 1 | student4 | 60.00 |
| Test assignment 1 | student5 | 50.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on a non-graded activity to show 3 high scores
Given I am on the "Test page name" "page activity" page
And I add the "Activity results" block to the default region with:
| config_activitygradeitemid | Test assignment 1 |
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "80.00" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"
@javascript @addablocklink
Scenario: Block should select current activity by default
Given I click on "Test assignment 1" "link" in the "region-main" "region"
When I add the "Activity results..." block
Then the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 1"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I click on "Test assignment 2" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 2"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I click on "Test assignment 3" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" matches value "Test assignment 3"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
And I am on "Course 1" course homepage
And I click on "Test page name" "link" in the "region-main" "region"
And I add the "Activity results..." block
And the field "config_activitygradeitemid" in the "Add Activity results block" "dialogue" does not match value "Test page name"
And I click on "Save changes" "button" in the "Add Activity results block" "dialogue"
@@ -0,0 +1,51 @@
@block @block_activity_results
Feature: The activity results block doesn't displays student scores for unconfigured block
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Add the block to a the course with Javascript disabled
Given I add the "Activity results" block
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"
@javascript
Scenario: Add the block to a the course with Javascript enabled
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"
Scenario: Try to configure the block on the course page in a course without activities
Given I add the "Activity results" block
When I configure the "Activity results" block
And I should see "There are not yet any activities in this course."
And I press "Save changes"
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"
Scenario: Try to configure the block on a resource page in a course without activities
Given the following "activity" exists:
| activity | page |
| course | C1 |
| idnumber | 0001 |
| name | Test page name |
| intro | Test page description |
| section | 1 |
| content | This is a page |
And I am on "Course 1" course homepage
When I add the "Activity results" block
And I configure the "Activity results" block
And I should see "There are not yet any activities in this course."
And I press "Save changes"
Then I should see "Please configure this block and select which activity it should display results from." in the "Activity results" "block"
@@ -0,0 +1,39 @@
@block @block_activity_results
Feature: The activity results block doesn't display student scores for unsupported activity
In order to be display student scores
As a user
I need to properly configure the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Try to configure the block to use an activity without grades
Given the following "activities" exist:
| activity | name | intro | course | section | idnumber | assignsubmission_file_enabled |
| assign | Test assignment | Offline text | C1 | 1 | assign1 | 0 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_results | Course | C1 | course-view-* | side-pre |
And I am on "Course 1" course homepage
And I configure the "Activity results" block
And I set the following fields to these values:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
And I press "Save changes"
When I am on the "Test assignment" "assign activity editing" page
And I set the following fields to these values:
| id_grade_modgrade_type | None |
And I press "Save and return to course"
Then I should see "Error: the activity selected uses a grading method that is not supported by this block." in the "Activity results" "block"
@@ -0,0 +1,62 @@
@block @block_activity_results
Feature: The activity results block can have administrator set defaults
In order to be customize the activity results block
As an admin
I need can assign some site wide defaults
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| assignsubmission_file_enabled | 0 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Assign some site-wide defaults to the block.
Given the following config values are set as admin:
| config_showbest | 0 | block_activity_results |
| config_showworst | 0 | block_activity_results |
| config_gradeformat | 2 | block_activity_results |
| config_nameformat | 2 | block_activity_results |
And I am on "Course 1" course homepage
And I add the "Activity results" block
When I configure the "Activity results" block
And the following fields match these values:
| config_showbest | 0 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display only ID numbers |
And I press "Save changes"
Then I should see "This block's configuration currently does not allow it to show any results." in the "Activity results" "block"
Scenario: Assign some site-wide defaults to the block and lock them.
Given the following config values are set as admin:
| config_showbest | 0 | block_activity_results |
| config_showbest_locked | 1 | block_activity_results |
| config_showworst | 0 | block_activity_results |
| config_showworst_locked | 1 | block_activity_results |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_results | Course | C1 | course-view-* | side-pre |
And I am on "Course 1" course homepage
When I configure the "Activity results" block
And the following fields match these values:
| config_showbest | 0 |
| config_showworst | 0 |
And the "config_showbest" "field" should be readonly
And the "config_showworst" "field" should be readonly
And I press "Save changes"
Then I should see "This block's configuration currently does not allow it to show any results." in the "Activity results" "block"
@@ -0,0 +1,140 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student high scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | section | idnumber | assignsubmission_file_enabled |
| assign | Test assignment | Offline text | C1 | 1 | assign1 | 0 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 90.00 |
| Test assignment | student2 | 80.00 |
| Test assignment | student3 | 70.00 |
| Test assignment | student4 | 60.00 |
| Test assignment | student5 | 50.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 0 high scores
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
Then I should see "This block's configuration currently does not allow it to show any results." in the "Activity results" "block"
Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90%" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "80%" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "80.00/100.00" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "80.00" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
Then I should see "User S1" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
And I should see "User S2" in the "Activity results" "block"
And I should see "80.00%" in the "Activity results" "block"
And I should see "User S3" in the "Activity results" "block"
And I should see "70.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
Then I should see "User" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
And I should see "80.00%" in the "Activity results" "block"
And I should see "70.00%" in the "Activity results" "block"
@@ -0,0 +1,98 @@
@block @block_activity_results @javascript
Feature: The activity results block displays students high scores in group as scales
In order to be display student scores as scales
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| intro | Offline text |
| assignsubmission_file_enabled | 0 |
And the following "scales" exist:
| name | scale |
| My Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
And I am on the "Test assignment" "assign activity editing" page logged in as teacher1
And I set the following fields to these values:
| id_grade_modgrade_type | Scale |
| id_grade_modgrade_scale | My Scale |
And I press "Save and return to course"
And I am on the "Course 1" "grades > Grader report > View" page
And I turn editing mode on
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 3" for the grade item "Test assignment"
And I give the grade "Average" to the user "Student 4" for the grade item "Test assignment"
And I give the grade "Not good enough" to the user "Student 5" for the grade item "Test assignment"
And I press "Save changes"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using full names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display full names |
Then I should see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display only ID numbers |
Then I should see "User S1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "User S2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "User S3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Anonymous results |
Then I should see "User" in the "Activity results" "block"
And I should not see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should not see "Student 2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should not see "Student 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
@@ -0,0 +1,132 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student in group high scores as scales
In order to be display student scores as scales
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activities" exist:
| activity | name | intro | course | section | idnumber |
| assign | Test assignment | Offline text | C1 | 1 | assign1 |
And the following "scales" exist:
| name | scale |
| My Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
And I change window size to "large"
And I am on the "Test assignment" "assign activity editing" page logged in as teacher1
And I set the following fields to these values:
| assignsubmission_file_enabled | 0 |
| id_grade_modgrade_type | Scale |
| id_grade_modgrade_scale | My Scale |
| Group mode | Separate groups |
And I press "Save and return to course"
And I turn editing mode on
And I am on the "Course 1" "grades > Grader report > View" page
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 3" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 4" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 5" for the grade item "Test assignment"
And I give the grade "Average" to the user "Student 6" for the grade item "Test assignment"
And I press "Save changes"
And I am on "Course 1" course homepage
Scenario: Try to configure the block on the course page to show 1 high score
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "Student 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using full names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student3
And I should see "Student 3" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
# Students cannot see user identity fields.
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should not see "User S1" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should not see "User S2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should see "Excellent!" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
@@ -0,0 +1,193 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student in separate groups scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| section | 1 |
| assignsubmission_file_enabled | 0 |
| groupmode | 1 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 100.00 |
| Test assignment | student2 | 90.00 |
| Test assignment | student3 | 90.00 |
| Test assignment | student4 | 80.00 |
| Test assignment | student5 | 80.00 |
| Test assignment | student6 | 70.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95.00/100.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "Student 1" in the "Activity results" "block"
And I should see "100.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "Student 1" in the "Activity results" "block"
And I should see "100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95%" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85%" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "Student 1" in the "Activity results" "block"
And I should see "100%" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "90%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95.00/100.00" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00/100.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student3
And I should see "Student 3" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "80.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95.00" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "Student 1" in the "Activity results" "block"
And I should see "100.00" in the "Activity results" "block"
And I should see "Student 2" in the "Activity results" "block"
And I should see "90.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "95.00%" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
# Students cannot see user identity fields.
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should not see "User S1" in the "Activity results" "block"
And I should see "100.00%" in the "Activity results" "block"
And I should not see "User S2" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "95.00%" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should see "100.00%" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
@@ -0,0 +1,163 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student in visible groups scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activities" exist:
| activity | name | course | idnumber | section | assignsubmission_file_enabled | groupmode |
| assign | Test assignment | C1 | assign1 | 1 | 0 | 2 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 100.00 |
| Test assignment | student2 | 90.00 |
| Test assignment | student3 | 90.00 |
| Test assignment | student4 | 80.00 |
| Test assignment | student5 | 80.00 |
| Test assignment | student6 | 70.00 |
And I am on the "Course 1" course page logged in as teacher1
And I turn editing mode on
Scenario: Configure the block on the course page to show 1 high score
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
And I am on the "Course 1" course page logged in as student1
Then I should see "Group 1" in the "Activity results" "block"
And I should see "95.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 high score as a absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 1 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 1" in the "Activity results" "block"
And I should see "95.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 1" in the "Activity results" "block"
And I should see "95%" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85%" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 1" in the "Activity results" "block"
And I should see "95.00/100.00" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00/100.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 1" in the "Activity results" "block"
And I should see "95.00" in the "Activity results" "block"
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group" in the "Activity results" "block"
And I should see "95.00%" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 3 |
| config_showworst | 0 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group" in the "Activity results" "block"
And I should see "95.00%" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
@@ -0,0 +1,135 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student low scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| assignsubmission_file_enabled | 0 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 90.00 |
| Test assignment | student2 | 80.00 |
| Test assignment | student3 | 70.00 |
| Test assignment | student4 | 60.00 |
| Test assignment | student5 | 50.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 1 low score
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a absolute number
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50%" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "60%" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50.00/100.00" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "60.00/100.00" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "50.00" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "60.00" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
Then I should see "User S5" in the "Activity results" "block"
And I should see "50.00%" in the "Activity results" "block"
And I should see "User S4" in the "Activity results" "block"
And I should see "60.00%" in the "Activity results" "block"
And I should see "User S3" in the "Activity results" "block"
And I should see "70.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
Then I should see "User" in the "Activity results" "block"
And I should see "50.00%" in the "Activity results" "block"
And I should see "60.00%" in the "Activity results" "block"
And I should see "70.00%" in the "Activity results" "block"
@@ -0,0 +1,100 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student low scores as scales
In order to be display student scores as scales
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
Given the following "activity" exists:
| activity | assign |
| name | Test assignment |
| intro | Offline text |
| course | C1 |
| idnumber | 0001 |
| section | 1 |
| assignsubmission_file_enabled | 0 |
And the following "scales" exist:
| name | scale |
| My Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
And I am on the "Test assignment" "assign activity editing" page logged in as teacher1
And I set the following fields to these values:
| id_grade_modgrade_type | Scale |
| id_grade_modgrade_scale | My Scale |
And I press "Save and return to course"
And I turn editing mode on
And I am on the "Course 1" "grades > Grader report > View" page
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 3" for the grade item "Test assignment"
And I give the grade "Average" to the user "Student 4" for the grade item "Test assignment"
And I give the grade "Not good enough" to the user "Student 5" for the grade item "Test assignment"
And I press "Save changes"
And I am on "Course 1" course homepage
Scenario: Configure the block on the course page to show 1 low score
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "Not good enough" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using full names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_nameformat | Display full names |
Then I should see "Student 5" in the "Activity results" "block"
And I should see "Not good enough" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
And I should see "Student 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_nameformat | Display only ID numbers |
Then I should see "User S5" in the "Activity results" "block"
And I should see "Not good enough" in the "Activity results" "block"
And I should see "User S4" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
And I should see "User S3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 3 |
| config_nameformat | Anonymous results |
Then I should see "User" in the "Activity results" "block"
And I should not see "Student 5" in the "Activity results" "block"
And I should see "Not good enough" in the "Activity results" "block"
And I should not see "Student 4" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
And I should not see "Student 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
@@ -0,0 +1,131 @@
@block @block_activity_results @javascript
Feature: The activity results block displays students in groups low scores as scales
In order to be display student scores as scales
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| description | Offline text |
| assignsubmission_file_enabled | 0 |
| groupmode | 1 |
And the following "scales" exist:
| name | scale |
| My Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
And I change window size to "large"
And I am on the "Test assignment" "assign activity editing" page logged in as teacher1
And I set the following fields to these values:
| id_grade_modgrade_type | Scale |
| id_grade_modgrade_scale | My Scale |
And I press "Save and return to course"
And I am on the "Course 1" "grades > Grader report > View" page
And I turn editing mode on
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment"
And I give the grade "Very good" to the user "Student 3" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 4" for the grade item "Test assignment"
And I give the grade "Good" to the user "Student 5" for the grade item "Test assignment"
And I give the grade "Average" to the user "Student 6" for the grade item "Test assignment"
And I press "Save changes"
And I am on "Course 1" course homepage
Scenario: Try to configure the block on the course page to show 1 low score
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "Student 6" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using full names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 2" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student3
And I should see "Student 3" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
# Students cannot see user identity fields.
And I am on the "Course 1" course page logged in as student5
And I should see "User" in the "Activity results" "block"
And I should not see "User S5" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I should not see "User S6" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple high scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "Very good" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "User" in the "Activity results" "block"
And I should see "Good" in the "Activity results" "block"
And I should see "Average" in the "Activity results" "block"
@@ -0,0 +1,180 @@
@block @block_activity_results @javascript
Feature: The activity results block displays students in separate groups scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activities" exist:
| activity | course | idnumber | name | assignsubmission_file_enabled | groupmode |
| assign | C1 | a1 | Test assignment | 0 | 1 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 100.00 |
| Test assignment | student2 | 90.00 |
| Test assignment | student3 | 90.00 |
| Test assignment | student4 | 80.00 |
| Test assignment | student5 | 80.00 |
| Test assignment | student6 | 70.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 1 low score
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "Student 6" in the "Activity results" "block"
And I should see "70.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "Student 6" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 2" in the "Activity results" "block"
And I should see "85%" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "Student 6" in the "Activity results" "block"
And I should see "70%" in the "Activity results" "block"
And I should see "Student 5" in the "Activity results" "block"
And I should see "80%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 2" in the "Activity results" "block"
And I should see "85.00/100.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student3
And I should see "Student 3" in the "Activity results" "block"
And I should see "90.00/100.00" in the "Activity results" "block"
And I should see "Student 4" in the "Activity results" "block"
And I should see "80.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I should see "Group 2" in the "Activity results" "block"
And I should see "85.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
And I should see "Student 5" in the "Activity results" "block"
And I should see "80.00" in the "Activity results" "block"
And I should see "Student 6" in the "Activity results" "block"
And I should see "70.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
# Students cannot see user identity fields.
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should not see "User S1" in the "Activity results" "block"
And I should see "100.00%" in the "Activity results" "block"
And I should not see "User S2" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I should see "Group" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student1
And I should see "User" in the "Activity results" "block"
And I should see "100.00%" in the "Activity results" "block"
And I should see "90.00%" in the "Activity results" "block"
@@ -0,0 +1,163 @@
@block @block_activity_results @javascript
Feature: The activity results block displays student in visible groups low scores
In order to be display student scores
As a user
I need to see the activity results block
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
| student2 | Student | 2 | student2@example.com | S2 |
| student3 | Student | 3 | student3@example.com | S3 |
| student4 | Student | 4 | student4@example.com | S4 |
| student5 | Student | 5 | student5@example.com | S5 |
| student6 | Student | 6 | student6@example.com | S6 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
| Group 3 | C1 | G3 |
| Group 4 | C1 | G4 |
| Group 5 | C1 | G5 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student3 | G2 |
| student4 | G2 |
| student5 | G3 |
| student6 | G3 |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| assignsubmission_file_enabled | 0 |
| groupmode | 2 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Test assignment | student1 | 100.00 |
| Test assignment | student2 | 90.00 |
| Test assignment | student3 | 90.00 |
| Test assignment | student4 | 80.00 |
| Test assignment | student5 | 80.00 |
| Test assignment | student6 | 70.00 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Scenario: Configure the block on the course page to show 1 low score
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a fraction
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show 1 low score as a absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 1 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
When I am on the "Course 1" course page logged in as student1
Then I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as percentages
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
| config_decimalpoints | 0 |
| config_usegroups | Yes |
Then I should see "Group 2" in the "Activity results" "block"
And I should see "85%" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
And I am on the "Course 1" course page logged in as student5
Then I should see "Group 2" in the "Activity results" "block"
And I should see "85%" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as fractions
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Fractions |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00/100.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00/100.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores as absolute numbers
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Absolute numbers |
| config_nameformat | Display full names |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group 2" in the "Activity results" "block"
And I should see "85.00" in the "Activity results" "block"
And I should see "Group 3" in the "Activity results" "block"
And I should see "75.00" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using ID numbers
Given the following config values are set as admin:
| showuseridentity | idnumber,email |
And I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Display only ID numbers |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
Scenario: Try to configure the block on the course page to show multiple low scores using anonymous names
Given I add the "Activity results" block to the default region with:
| config_showbest | 0 |
| config_showworst | 2 |
| config_gradeformat | Percentages |
| config_nameformat | Anonymous results |
| config_usegroups | Yes |
Then I am on the "Course 1" course page logged in as student1
And I should see "Group" in the "Activity results" "block"
And I should see "85.00%" in the "Activity results" "block"
And I should see "75.00%" in the "Activity results" "block"
+29
View File
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version information for the block_activity_results plugin.
*
* @package block_activity_results
* @copyright 2015 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'block_activity_results'; // Full name of the plugin (used for diagnostics).