Commit 0d8609f6 authored by Camille Tardy's avatar Camille Tardy
Browse files

Moodle code checker fix


Signed-off-by: Camille Tardy's avatarCamille Tardy <camille.tardy@unige.ch>
parent 1d1bd169
......@@ -29,7 +29,6 @@ require_once($CFG->dirroot . '/mod/quiz/report/group/locallib.php');
* @copyright 2017 Camille Tardy, University of Geneva
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class quiz_group_observer{
/**
......@@ -44,36 +43,35 @@ class quiz_group_observer{
$attempt = $event->get_data();
$cm = $PAGE->cm;
$quiz_id = $cm->instance;
$groupingid = get_groupquiz_groupingid($quiz_id);
$quizid = $cm->instance;
$groupingid = get_groupquiz_groupingid($quizid);
if($groupingid == null || $groupingid ==0){
if ($groupingid == null || $groupingid == 0) {
// if grp_quiz is not enabled do nothing
}else{
} else {
//check if a user from the same group is trying to attempt quiz when we already have an attempt for this group.
$user_grp = get_user_group_for_groupquiz($attempt['userid'], $quiz_id, $attempt['courseid']);
$usergrp = get_user_group_for_groupquiz($attempt['userid'], $quizid, $attempt['courseid']);
$attempt_grp_inDB = $DB->get_records('quiz_group_attempts', array('quizid'=>$quiz_id, 'groupid'=>$user_grp, 'groupingid'=>$groupingid));
if (!empty($attempt_grp_inDB)){
$attemptgrpindb = $DB->get_records('quiz_group_attempts', array('quizid' => $quizid, 'groupid' => $usergrp, 'groupingid' => $groupingid));
if (!empty($attemptgrpindb)) {
// An attempt already exist for this group block current user attempt
$grp_attemptID = 0;
$grp_name = $DB->get_field('groups', 'name', array('id'=>$user_grp));
$grpattemptid = 0;
$grpname = $DB->get_field('groups', 'name', array('id'=>$usergrp));
//return to view quiz page with message : warning(yellow) --> NOTIFY_WARNING // error(red) --> NOTIFY_ERROR
redirect(new moodle_url('/mod/quiz/view.php', array('id' => $cm->id)), get_string('group_attempt_already_created', 'quiz_group', $grp_name), null, \core\output\notification::NOTIFY_ERROR);
redirect(new moodle_url('/mod/quiz/view.php', array('id' => $cm->id)), get_string('group_attempt_already_created', 'quiz_group', $grpname), null, \core\output\notification::NOTIFY_ERROR);
}else{
} else {
// no attempt yet for this group : proceed with current user
$group_attempt = quiz_group_attempt_to_groupattempt_dbobject($attempt, $quiz_id, $user_grp, $groupingid);
$groupattempt = quiz_group_attempt_to_groupattempt_dbobject($attempt, $quizid, $usergrp, $groupingid);
//save in DB
$grp_attemptID = $DB->insert_record('quiz_group_attempts', $group_attempt, true);
$grpattemptid = $DB->insert_record('quiz_group_attempts', $groupattempt, true);
}
return $grp_attemptID;
return $grpattemptid;
}
......@@ -86,35 +84,35 @@ class quiz_group_observer{
* @param \mod_quiz\event\attempt_submitted $event
* @return bool
*/
public static function attempt_submitted(core\event\base $event){
public static function attempt_submitted(core\event\base $event) {
global $DB;
$attempt = $event->get_data();
$quiz_id = $attempt['other']['quizid'];
$user_id = $attempt['userid'];
$attempt_id = $attempt['objectid'];
$course_id = $attempt['courseid'];
$quizid = $attempt['other']['quizid'];
$userid = $attempt['userid'];
$attemptid = $attempt['objectid'];
$courseid = $attempt['courseid'];
$groupingid = get_groupquiz_groupingid($quiz_id);
$groupingid = get_groupquiz_groupingid($quizid);
if($groupingid == null || $groupingid ==0){
if ($groupingid == null || $groupingid == 0) {
// of grp_quiz is not enabled do nothing
}else{
} else {
$gid = get_user_group_for_groupquiz($user_id, $quiz_id, $course_id);
$gid = get_user_group_for_groupquiz($userid, $quizid, $courseid);
//retrieve grp attempt object
$grp_attempt = $DB->get_record('quiz_group_attempts', array('groupid'=>$gid, 'quizid'=>$quiz_id));
$grpattempt = $DB->get_record('quiz_group_attempts', array('groupid' => $gid, 'quizid' => $quizid));
if(!empty($grp_attempt)){
if (!empty($grpattempt)) {
//edit grp attempt
$grp_attempt->attemptid = $attempt_id;
$grpattempt->attemptid = $attemptid;
//save in DB
$DB->update_record('quiz_group_attempts', $grp_attempt, false);
}else {
$DB->update_record('quiz_group_attempts', $grpattempt, false);
} else {
//ERROR : Grp attempt not in DB
//create grp_attempt if not in DB
create_groupattempt_from_attempt($attempt,$course_id);
create_groupattempt_from_attempt($attempt,$courseid);
}
}
......@@ -132,15 +130,15 @@ class quiz_group_observer{
global $DB;
$attempt = $event->get_data();
$quiz_id = $attempt['other']['quizid'];
// $attempt_id = $attempt['objectid'];
$user_id = $attempt['relateduserid'];
$quizid = $attempt['other']['quizid'];
// $attemptid = $attempt['objectid'];
$userid = $attempt['relateduserid'];
//attempt can be null in grp_attempt if attempt never submitted by user
//better to retreive attempt via quizid and userid
//delete record in DB
$DB->delete_records('quiz_group_attempts', array('quizid'=>$quiz_id, 'userid'=>$user_id));
$DB->delete_records('quiz_group_attempts', array('quizid' => $quizid, 'userid' => $userid));
return true ;
}
......@@ -170,9 +168,9 @@ class quiz_group_observer{
// $groupid = get_user_group_for_groupquiz($userid, $quizid, $courseid);
//delete record in DB for group in quiz
$DB->delete_records('quiz_group_attempts', array('quizid'=>$quizid, 'userid'=>$userid));
$DB->delete_records('quiz_group_attempts', array('quizid' => $quizid, 'userid' => $userid));
return true ;
return true;
}
......
......@@ -36,7 +36,7 @@ $observers = array(
'callback' => 'quiz_group_observer::attempt_submitted',
),
//catch attempt abandoned
// catch attempt abandoned
array(
'eventname' => '\mod_quiz\event\attempt_abandoned',
'callback' => 'quiz_group_observer::attempt_abandoned',
......
......@@ -39,19 +39,19 @@ class quiz_group_dispatchgrade_form extends moodleform {
protected function definition() {
//todo: disable if no attempt
// todo: disable if no attempt
$mform_dispatch = $this->_form;
$mform_dispatch->addElement('header', 'quizgroupdispatchgrades', get_string('titleapply', 'quiz_group'));
$mform_dispatch->addElement('html', "<p>".get_string('info_dispatchgrades', 'quiz_group')."</p>");
$mform_dispatch->addElement('hidden', 'groupingid');
$mform_dispatch->setType('groupingid',PARAM_INT);
$mformdispatch = $this->_form;
$mformdispatch->addElement('header', 'quizgroupdispatchgrades', get_string('titleapply', 'quiz_group'));
$mformdispatch->addElement('html', "<p>".get_string('info_dispatchgrades', 'quiz_group')."</p>");
$mformdispatch->addElement('hidden', 'groupingid');
$mformdispatch->setType('groupingid', PARAM_INT);
//submit button
$mform_dispatch->addElement('submit', 'dispatch', get_string('apply', 'quiz_group'));
// submit button
$mformdispatch->addElement('submit', 'dispatch', get_string('apply', 'quiz_group'));
}
function validation($data, $files) {
//No form validation needed.
// No form validation needed.
}
}
......@@ -44,7 +44,7 @@ class quiz_group_settings_form extends moodleform {
$mform->addElement('header', 'quizgroupsubmission', get_string('quizgroup', 'quiz_group'));
//todo : fix hasattempt --> kills action button return url (bad quiz id)
// todo : fix hasattempt --> kills action button return url (bad quiz id)
// if attempt block edit.
/* $mform->addElement('hidden', 'hasattempts');
$mform->setType('hasattempts',PARAM_BOOL);
......@@ -60,7 +60,7 @@ class quiz_group_settings_form extends moodleform {
$mform->addElement('html', "<h4>".get_string('title_groupingselect', 'quiz_group')."</h4>");
//get grouping list from course
// get grouping list from course
$groupings = groups_get_all_groupings($COURSE->id);
$options = array();
$options[0] = get_string('no_grouping', 'quiz_group');
......@@ -71,15 +71,14 @@ class quiz_group_settings_form extends moodleform {
// create select element and pre-select current value
$mform->addElement('select', 'sel_groupingid', get_string('teamsubmissiongroupingid', 'assign'), $options);
//submit button
$mform->addElement('submit', 'savechanges', get_string('savechanges', 'quiz_group'));
//$mform->disabledIf('submitbutton', 'hasattempts', 'eq',true);
//$mform->disabledIf('sel_groupingid', 'hasattempts', 'eq',true);
// $mform->disabledIf('submitbutton', 'hasattempts', 'eq',true);
// $mform->disabledIf('sel_groupingid', 'hasattempts', 'eq',true);
}
function validation($data, $files) {
//No form validation needed yet.
// No form validation needed yet.
}
}
......@@ -34,7 +34,7 @@ $string['settings_edited'] = 'The quiz has been edited with the following groupi
$string['title_groupingselect'] = 'Choose the grouping for the quiz';
$string['no_group_string'] = 'No grouping';
$string['quiz_has_attempts'] = 'This quiz already has attempts. You can no longer update the group setting.';
$string['canceledit'] ='You have canceled the edition of group setting.';
$string['canceledit'] = 'You have canceled the edition of group setting.';
$string['group_attempt_already_created'] = 'An attempt for this Group quiz for your group : {$a}, already exist.';
$string['titleapply'] = 'Transfer group grades';
......
......@@ -35,7 +35,7 @@ $string['settings_edited'] = 'Le test a bien été modifié avec le groupement :
$string['title_groupingselect'] = 'Choisissez le groupement pour le test';
$string['no_group_string'] = 'Pas de groupement';
$string['quiz_has_attempts'] = 'Ce test a des participations. Vous ne pouvez plus modifier les paramètres de groupe.';
$string['canceledit'] ='Edition du paramettre de groupe annulé.';
$string['canceledit'] = 'Edition du paramettre de groupe annulé.';
$string['group_attempt_already_created'] = 'Une participation à ce test en groupe pour votre groupe : {$a}, existe déjà.';
$string['titleapply'] = 'Transmettre les notes de groupe';
$string['apply'] = 'Appliquer les notes';
......
......@@ -30,22 +30,21 @@ defined('MOODLE_INTERNAL') || die();
/**
* Return grouping used in Group quiz or false if not found
* @param $quizid
* @param int $quizid
* @return int $groupingid
*/
function get_groupquiz_groupingid($quizid){
function get_groupquiz_groupingid($quizid) {
global $DB;
//todo use get_fieldset_select instead of get_record ??
$quiz_group_groupingid = $DB->get_record('quiz_group', array('quizid'=>$quizid), 'groupingid', 'IGNORE_MISSING');
$quizgroupgroupingid = $DB->get_record('quiz_group', array('quizid' => $quizid), 'groupingid', 'IGNORE_MISSING');
if($quiz_group_groupingid == false){
if ($quizgroupgroupingid == false) {
$groupingid = null;
}else{
$groupingid = $quiz_group_groupingid->groupingid;
} else {
$groupingid = $quizgroupgroupingid->groupingid;
}
return $groupingid;
}
......@@ -60,40 +59,40 @@ function get_groupquiz_groupingid($quizid){
*
* @return int $grpid
*/
function get_user_group_for_groupquiz($userid, $quizid, $courseid, $groupingid = null){
function get_user_group_for_groupquiz($userid, $quizid, $courseid, $groupingid = null) {
// retreive all groups for user
$user_grpids = groups_get_user_groups($courseid, $userid);
//keep only grp ids
$user_grps = array();
foreach ($user_grpids as $key=>$gpid){
foreach ($gpid as $k=>$gid) {
$usergrpids = groups_get_user_groups($courseid, $userid);
// keep only grp ids
$usergrps = array();
foreach ($usergrpids as $key => $gpid) {
foreach ($gpid as $k => $gid) {
// if not alreday in array add id
if (!in_array($gid, $user_grps, false)){
$user_grps[] = $gid;
if (!in_array($gid, $usergrps, false)) {
$usergrps[] = $gid;
}
}
}
// retrieve grouping ID used in Quiz_group
if($groupingid == null ){
if ($groupingid == null ) {
$groupingid = get_groupquiz_groupingid($quizid);
}
// filter group from grouping.
$grpsingrouping = groups_get_all_groups(intval($courseid), null ,intval($groupingid));
$grps_in_ging = array();
//keep only grp ids
foreach ($grpsingrouping as $gp){
$grps_in_ging[] = $gp->id;
$grpsingrouping = groups_get_all_groups(intval($courseid), null, intval($groupingid));
$grpsinging = array();
// keep only grp ids
foreach ($grpsingrouping as $gp) {
$grpsinging[] = $gp->id;
}
//compare the 2 arrays and retrieve group id
// compare the 2 arrays and retrieve group id
$grpid = 0;
$grps_intersect = array_intersect($user_grps, $grps_in_ging);
//if not empty grp_intersect pick the first group.
$grpsintersect = array_intersect($usergrps, $grpsinging);
// if not empty grp_intersect pick the first group.
if (!empty($grps_intersect)){
$grpid = $grps_intersect[0];
if (!empty($grpsintersect)) {
$grpid = $grpsintersect[0];
}
return $grpid;
......@@ -108,29 +107,28 @@ function get_user_group_for_groupquiz($userid, $quizid, $courseid, $groupingid =
* @param int $grpid
* @param int $groupingid
*
* @return object $grp_attempt
* @return group_attempt $grp_attempt
*/
function quiz_group_attempt_to_groupattempt_dbobject($attempt, $quizid, $grpid, $groupingid){
function quiz_group_attempt_to_groupattempt_dbobject($attempt, $quizid, $grpid, $groupingid) {
//fetch the informations
// fetch the informations
$userid = $attempt['userid'];
//$courseid = $attempt['courseid'];
// $courseid = $attempt['courseid'];
//get user grp for given quiz
//$grpid = get_user_group_for_groupquiz($userid, $quiz_id, $courseid);
// get user grp for given quiz
// $grpid = get_user_group_for_groupquiz($userid, $quiz_id, $courseid);
// fill in the group_attempt object
$grp_attempt = new \stdClass();
//attemptid cannot be found here as attempt not yet saved in DB, set default to null;
$grp_attempt->attemptid = null;
$grp_attempt->quizid = $quizid;
$grp_attempt->userid = $userid;
$grp_attempt->groupid = $grpid;
$grp_attempt->groupingid = $groupingid;
$grp_attempt->timemodified = time();
return $grp_attempt;
$grpattempt = new \stdClass();
// attemptid cannot be found here as attempt not yet saved in DB, set default to null;
$grpattempt->attemptid = null;
$grpattempt->quizid = $quizid;
$grpattempt->userid = $userid;
$grpattempt->groupid = $grpid;
$grpattempt->groupingid = $groupingid;
$grpattempt->timemodified = time();
return $grpattempt;
}
......@@ -138,32 +136,31 @@ function quiz_group_attempt_to_groupattempt_dbobject($attempt, $quizid, $grpid,
* Create group attempt in DB
* from quiz attempt in DB
*
* @param $attempt
* @param $courseid
* @param attempt $attempt
* @param int $courseid
*/
function create_groupattempt_from_attempt($attempt,$courseid)
{
function create_groupattempt_from_attempt($attempt, $courseid) {
global $DB;
$userid = $attempt->userid;
$quizid = $attempt->quiz;
$groupingid = get_groupquiz_groupingid($quizid);
$grp_att = new stdClass();
$grp_att->attemptid = $attempt->id;
$grp_att->quizid = $quizid;
$grp_att->groupingid =
$grp_att->timemodified = time(); //now
$grpatt = new stdClass();
$grpatt->attemptid = $attempt->id;
$grpatt->quizid = $quizid;
$grpatt->groupingid =
$grpatt->timemodified = time(); //now
$grp_att->groupid = get_user_group_for_groupquiz($userid, $quizid, $courseid, $groupingid);
$grpatt->groupid = get_user_group_for_groupquiz($userid, $quizid, $courseid, $groupingid);
/*if($groupingid == null || $groupingid ==0){
//DO nothing grp is not a grp quiz
}else */
if($groupingid>0 && $grp_att->groupid > 0){
if ($groupingid > 0 && $grpatt->groupid > 0) {
//create grp attempt in DB
$DB->insert_record('quiz_group_attempts', $grp_att);
}else if($groupingid>0 && $grp_att->groupid == 0){
$DB->insert_record('quiz_group_attempts', $grpatt);
} else if($groupingid>0 && $grpatt->groupid == 0) {
//do not save group attempt if its value is 0, and display error message
//dispaly error message user not in grouing selected for group quiz
\core\notification::error(get_string('user_notin_grouping', 'quiz_group'));
......@@ -179,91 +176,91 @@ function create_groupattempt_from_attempt($attempt,$courseid)
* @param int $groupingID
*
*/
function dispatch_grade($quiz, $groupingID) {
function dispatch_grade($quiz, $groupingid) {
global $DB, $PAGE;
$quizid = $quiz->id;
$courseid = $PAGE->course->id;
$grp_attempts_array = $DB->get_records('quiz_group_attempts', array('quizid'=>$quizid, 'groupingid'=>$groupingID));
$grpattemptsarray = $DB->get_records('quiz_group_attempts', array('quizid' => $quizid, 'groupingid' => $groupingid));
//change order of fields to get userid as index for grade array.
$quizgrades_array = $DB->get_records('quiz_grades', array('quiz'=>$quizid), '', 'userid, id, quiz, grade, timemodified');
// $quizattempts_array = $DB->get_records('quiz_attempts', array('quiz'=>$quizid, 'state' =>'finished'));
$quizgradesarray = $DB->get_records('quiz_grades', array('quiz' => $quizid), '', 'userid, id, quiz, grade, timemodified');
// $quizattemptsarray = $DB->get_records('quiz_attempts', array('quiz' => $quizid, 'state' => 'finished'));
//if no grp attempt : create from DB if they exist.
if(empty($grp_attempts_array)){
if (empty($grpattemptsarray)) {
//check if attempts exist in attempt table that didnt get saved in grp attempt dB; if yes copy them in grp attempt table
$quizattempts_array = $DB->get_records('quiz_attempts', array('quiz'=>$quizid, 'state' =>'finished'));
$quizattemptsarray = $DB->get_records('quiz_attempts', array('quiz' => $quizid, 'state' => 'finished'));
foreach ($quizattempts_array as $att){
foreach ($quizattemptsarray as $att) {
//if user not in correct grouping do not create
$grpid = get_user_group_for_groupquiz($att->userid, $quizid, $courseid);
if($grpid > 0){
create_groupattempt_from_attempt($att,$courseid);
if ($grpid > 0) {
create_groupattempt_from_attempt($att, $courseid);
}// if user not in grouping do not create grp_attempt
}
}
foreach ($grp_attempts_array as $grp_attempt){
foreach ($grpattemptsarray as $grpattempt) {
//get group id
$groupid = $grp_attempt->groupid;
$attemptid = $grp_attempt->attemptid;
$groupid = $grpattempt->groupid;
$attemptid = $grpattempt->attemptid;
//get attempt for grp_attempt
$attempt = $DB->get_record('quiz_attempts', array('id'=>$attemptid));
$attempt = $DB->get_record('quiz_attempts', array('id' => $attemptid));
//get all user for group id
$users = groups_get_members($groupid, 'u.id');
//retrieve grade from this user
$insert_grade = new \stdClass();
foreach($quizgrades_array as $qg){
if ($qg->userid == $attempt->userid){
$insertgrade = new \stdClass();
foreach ($quizgradesarray as $qg) {
if ($qg->userid == $attempt->userid) {
// copy grade value to insert item
$insert_grade->quiz = $qg->quiz;
$insert_grade->userid = $qg->userid;
$insert_grade->grade = $qg->grade;
$insert_grade->timemodified = $qg->timemodified;
$insertgrade->quiz = $qg->quiz;
$insertgrade->userid = $qg->userid;
$insertgrade->grade = $qg->grade;
$insertgrade->timemodified = $qg->timemodified;
}
}
//duplicate grade for each user iin list
foreach ($users as $u){
foreach ($users as $u) {
//delete current user of users list
if ($u->id == $attempt->userid){
if ($u->id == $attempt->userid) {
// user of original grade, do nothing
}else{
} else {
// Deal with quiz grade table
$insert_grade->userid = $u->id;
$insertgrade->userid = $u->id;
// if not already in DB
$user_quiz_grade_db = $DB->get_record('quiz_grades', array('quiz'=>$quizid, 'userid'=>$u->id));
if ($user_quiz_grade_db == false){
$userquizgradedb = $DB->get_record('quiz_grades', array('quiz' => $quizid, 'userid' => $u->id));
if ($userquizgradedb == false) {
// if not exist insert in DB
$DB->insert_record('quiz_grades', $insert_grade, false);
$DB->insert_record('quiz_grades', $insertgrade, false);
// echo 'ok insert grade user :'.$u->id.'<br/>';
}else if ($user_quiz_grade_db->grade !== $qg->grade){
} else if ($userquizgradedb->grade !== $qg->grade) {
// if exist but grade different, update grade
$update= new stdClass();
$update->id = $quizgrades_array[$u->id]->id;
$update->grade = $insert_grade->grade;
$update->id = $quizgradesarray[$u->id]->id;
$update->grade = $insertgrade->grade;
$DB->update_record('quiz_grades', $update, false);
}
// Deal with gradeBook
//get user grade for quiz
$grade_forquiz = quiz_get_user_grades($quiz, $u->id);
if($grade_forquiz && ($grade_forquiz[$u->id]->rawgrade !== $insert_grade->grade)){
$gradeforquiz = quiz_get_user_grades($quiz, $u->id);
if ($gradeforquiz && ($gradeforquiz[$u->id]->rawgrade !== $insertgrade->grade)) {
//if exist, update if grade is different
quiz_grade_item_update($quiz, $grade_forquiz);
}else if(empty($grade_forquiz)){
//if dont exist create grade
quiz_grade_item_update($quiz, $gradeforquiz);
} else if (empty($gradeforquiz)) {
//if don't exist create grade
$grade = new stdClass();
$grade->userid = $u->id;
$grade->rawgrade = $insert_grade->grade;
$grade->rawgrade = $insertgrade->grade;
quiz_grade_item_update($quiz, $grade);
......@@ -294,24 +291,24 @@ function quiz_process_group_deleted_in_course($courseid) {
// get course group (return : array of group objects (id, courseid, name, enrolmentkey)
// translate in text list the ids
$groups = $DB->get_records('groups', array('courseid'=>$courseid),'', 'id');
$groups_list = "";
foreach($groups as $g){
$groups_list.= '"'.$g->id.'",';
$groups = $DB->get_records('groups', array('courseid' => $courseid),'', 'id');
$groupslist = "";
foreach ($groups as $g) {
$groupslist.= '"'.$g->id.'",';
}
//get all course quizs id
$quizs_id = $DB->get_records('quiz', array('course'=>$courseid), '', 'id, name');
$quizsid = $DB->get_records('quiz', array('course' => $courseid), '', 'id, name');
//get all grp attempts foreach quizs id ang groups not in list (--> deleted)
foreach($quizs_id as $key=>$q){
foreach ($quizsid as $key => $q) {
$sql = "SELECT id FROM {quiz_group_attempts} WHERE quizid = ? AND groupid NOT IN (?)";
$grp_attempts_id = $DB->get_records_sql($sql, array($q->id, $groups_list));
$grpattemptsid = $DB->get_records_sql($sql, array($q->id, $groupslist));
//delete each grp attempt from deleted grp
foreach($grp_attempts_id as $ga){
foreach ($grpattemptsid as $ga) {
//delete record in DB
$att_id = $ga->id;
$DB->delete_records('quiz_group_attempts', array('id'=>$att_id));
$attid = $ga->id;
$DB->delete_records('quiz_group_attempts', array('id'=>$attid));
}
}
......
......@@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/group/locallib.php');
* @copyright 2017 Camille Tardy, University of Geneva
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quiz_group_report extends quiz_default_report{
class quiz_group_report extends quiz_default_report {
protected $viewoptions = array();
protected $questions;
......@@ -51,8 +51,7 @@ class quiz_group_report extends quiz_default_report{
* @param the $cm
* @param this $course
*/
public function display($quiz, $cm, $course)
{
public function display($quiz, $cm, $course) {
global $DB;
// global $OUTPUT;
......@@ -66,27 +65,27 @@ class quiz_group_report extends quiz_default_report{
// retrieve current grouping value for the given quizid return false if not found
$grouping_record = $DB->get_record('quiz_group', array('quizid'=>$quiz->id), 'id, groupingid', 'IGNORE_MISSING');
$groupingrecord = $DB->get_record('quiz_group', array('quizid'=>$quiz->id), 'id, groupingid', 'IGNORE_MISSING');
$groupingID = 0;
$groupingid = 0;
// if grouping id exist use the ID else set to 0 (-> no grouping selected)
if ($grouping_record!==false){
$groupingID = $grouping_record->groupingid;
if ($groupingrecord !== false) {
$groupingid = $groupingrecord->groupingid;
}