Commit aeb15530 authored by Petr Skoda's avatar Petr Skoda
Browse files

MDL-20700 coding style cleanup - cvs keywords removed, closign php tag...

MDL-20700 coding style cleanup - cvs keywords removed, closign php tag removed, trailing whitespace cleanup
parent cb8a83bb
<?php // $Id$
<?php // $Id$
////////////////////////////////////////////////////////////////////
/// Default class for report plugins
///
/// Doesn't do anything on it's own -- it needs to be extended.
/// This class displays quiz reports. Because it is called from
/// Default class for report plugins
///
/// Doesn't do anything on it's own -- it needs to be extended.
/// This class displays quiz reports. Because it is called from
/// within /mod/quiz/report.php you can assume that the page header
/// and footer are taken care of.
///
/// This file can refer to itself as report.php to pass variables
/// to itself - all these will also be globally available. You must
///
/// This file can refer to itself as report.php to pass variables
/// to itself - all these will also be globally available. You must
/// pass "id=$cm->id" or q=$quiz->id", and "mode=reportname".
////////////////////////////////////////////////////////////////////
......@@ -30,17 +30,17 @@ class quiz_default_report {
$PAGE->set_title(format_string($quiz->name));
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'quiz'));
echo $OUTPUT->header();
/// Print the tabs
/// Print the tabs
$currenttab = 'reports';
$mode = $reportmode;
require($CFG->dirroot . '/mod/quiz/tabs.php');
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
}
}
}
?>
<?php // $Id$
<?php
/**
* Quiz report to help teachers manually grade quiz questions that need it.
*
......@@ -128,13 +128,13 @@ class quiz_grading_report extends quiz_default_report {
"quiz=?", array_merge(array($uniqueid), $params, array($quiz->id)))){
print_error('invalidattemptid', 'quiz_grading');
}
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state = &$states[$question->id];
// the following will update the state and attempt
$error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']);
if (is_string($error)) {
......@@ -205,7 +205,7 @@ class quiz_grading_report extends quiz_default_report {
// our 2 different views
// the first view allows a user to select a question and
// the first view allows a user to select a question and
// displays the users who have answered the essay question
// and all of their attempts at answering the question
......@@ -456,7 +456,7 @@ class quiz_grading_report extends quiz_default_report {
$where = "WHERE u.id $usql ";
$params = array_merge($params, $u_params);
}
$where .= ' AND qs.event IN ('.QUESTION_EVENTS_CLOSED_OR_GRADED.')';
$where .= ' AND u.id = qa.userid AND qa.quiz = ?';
......@@ -471,4 +471,4 @@ class quiz_grading_report extends quiz_default_report {
}
?>
<?php // $Id$
<?php
function xmldb_quiz_overview_upgrade($oldversion) {
global $CFG, $DB;
......@@ -37,4 +37,4 @@ function xmldb_quiz_overview_upgrade($oldversion) {
return $result;
}
?>
<?php // $Id$
<?php
class quiz_report_overview_table extends table_sql {
......@@ -231,7 +231,7 @@ class quiz_report_overview_table extends table_sql {
$link = html_link::make("/mod/quiz/reviewquestion.php?attempt=$attempt->attempt&question=$question->id", $grade);
$link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650)));
$link->title = get_string('reviewresponsetoq', 'quiz', $question->formattedname);
$linktopopup = $OUTPUT->link($link);
$linktopopup = $OUTPUT->link($link);
if (($this->questions[$questionid]->maxgrade != 0)){
$fractionofgrade = $stateforqinattempt->grade
......@@ -331,4 +331,4 @@ class quiz_report_overview_table extends table_sql {
}
}
}
?>
<?php // $Id$
<?php
include '../../../../config.php';
include $CFG->dirroot."/lib/graphlib.php";
include $CFG->dirroot."/mod/quiz/report/reportlib.php";
......@@ -96,4 +96,4 @@ while ($gridlines >= 10){
$line->parameter['y_axis_gridlines'] = $gridlines+1;
$line->draw();
?>
<?php // $Id$
<?php
require_once "$CFG->libdir/formslib.php";
class mod_quiz_report_overview_settings extends moodleform {
......@@ -42,7 +42,7 @@ class mod_quiz_report_overview_settings extends moodleform {
}
if ($showattemptsgrp){
$mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '<br />', false);
}
}
//-------------------------------------------------------------------------------
$mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview'));
......@@ -54,4 +54,4 @@ class mod_quiz_report_overview_settings extends moodleform {
$this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview'));
}
}
?>
......@@ -2,7 +2,6 @@
/**
* This script lists student attempts
*
* @version $Id$
* @author Martin Dougiamas, Tim Hunt and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
......@@ -32,7 +31,7 @@ class quiz_overview_report extends quiz_default_report {
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$download = optional_param('download', '', PARAM_ALPHA);
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
if (!$students = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','','','',false)){
......@@ -54,7 +53,7 @@ class quiz_overview_report extends quiz_default_report {
}
$allowed = $groupstudents;
}
if (empty($currentgroup)||$groupstudents) {
if (optional_param('delete', 0, PARAM_BOOL)){
if($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
......@@ -129,7 +128,7 @@ class quiz_overview_report extends quiz_default_report {
} else if ($attemptsmode === null){
//default
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
}
}
if (!$reviewoptions->scores) {
$detailedmarks = 0;
}
......@@ -162,7 +161,7 @@ class quiz_overview_report extends quiz_default_report {
// Only print headers if not asked to download data
$this->print_header_and_tabs($cm, $course, $quiz, "overview");
}
if ($regradeall){
$this->regrade_all(false, $quiz, $groupstudents);
} else if ($regradealldry){
......@@ -173,14 +172,14 @@ class quiz_overview_report extends quiz_default_report {
if ($regradeall || $regradealldry || $regradealldrydo){
redirect($reporturl->out(false, $displayoptions, false), '', 5);
}
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$table->is_downloading()) {
groups_print_activity_menu($cm, $reporturl->out(false, $displayoptions));
}
}
// Print information on the number of existing attempts
if (!$table->is_downloading()) { //do not print notices when downloading
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) {
......@@ -200,14 +199,14 @@ class quiz_overview_report extends quiz_default_report {
$mform->set_data($displayoptions +compact('detailedmarks', 'pagesize'));
$mform->display();
}
if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)){
// Construct the SQL
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, ';
if ($qmsubselect) {
......@@ -217,7 +216,7 @@ class quiz_overview_report extends quiz_default_report {
" ELSE 0 " .
"END) AS gradedattempt, ";
}
$fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
......@@ -226,7 +225,7 @@ class quiz_overview_report extends quiz_default_report {
$from = '{user} u ';
$from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid';
$params = array('quizid' => $quiz->id);
if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
......@@ -254,7 +253,7 @@ class quiz_overview_report extends quiz_default_report {
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
break;
}
$table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params);
$sqlobject = new object;
......@@ -272,7 +271,7 @@ class quiz_overview_report extends quiz_default_report {
$where .= ' AND COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_question_regrade} qqr WHERE qqr.attemptid = qa.uniqueid),-1) !=\'-1\'';
}
$table->set_sql($fields, $from, $where, $params);
// Define table columns
$columns = array();
$headers = array();
......@@ -311,12 +310,12 @@ class quiz_overview_report extends quiz_default_report {
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
}
}
if (!$table->is_downloading() && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
}
if (!$table->is_downloading() && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
......@@ -330,21 +329,21 @@ class quiz_overview_report extends quiz_default_report {
$columns[]= 'firstname';
$headers[]= get_string('firstname');
}
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
}
$columns[]= 'timestart';
$headers[]= get_string('startedon', 'quiz');
$columns[]= 'timefinish';
$headers[]= get_string('timecompleted','quiz');
$columns[]= 'duration';
$headers[]= get_string('attemptduration', 'quiz');
if ($detailedmarks) {
foreach ($questions as $id => $question) {
// Ignore questions of zero length
......@@ -368,35 +367,35 @@ class quiz_overview_report extends quiz_default_report {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade);
}
if ($hasfeedback) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'uniqueid');
// Set up the table
$table->define_baseurl($reporturl->out(false, $displayoptions));
$table->collapsible(false);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('feedbacktext');
$table->column_class('picture', 'picture');
$table->column_class('lastname', 'bold');
$table->column_class('firstname', 'bold');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
$table->set_attribute('id', 'attempts');
$table->out($pagesize, true);
}
if (!$table->is_downloading() && $showgrades) {
......@@ -648,7 +647,7 @@ class quiz_overview_report extends quiz_default_report {
list($asql, $aparams) = $DB->get_in_or_equal($attemptids);
$where = "qa.id $asql AND ";
$params = array_merge($params, $aparams);
$where .= "qa.quiz = ? AND qa.preview = 0";
$params[] = $quiz->id;
if (!$attempts = $DB->get_records_sql('SELECT qa.* FROM {quiz_attempts} qa WHERE '. $where, $params)) {
......@@ -671,4 +670,4 @@ class quiz_overview_report extends quiz_default_report {
}
?>
<?php // $Id$
<?php
////////////////////////////////////////////////////////////////////////////////
// Code fragment to define the version of quiz overview report
......@@ -7,4 +7,4 @@
$plugin->version = 2009091400; // The (date) version of this module
?>
......@@ -119,7 +119,7 @@ function quiz_get_average_grade_for_questions($quiz, $userids){
list($usql, $params) = $DB->get_in_or_equal($userids);
$params[] = $quiz->id;
$questionavgssql = "SELECT qns.questionid, AVG(qs.grade) FROM
{quiz_attempts} qa
{quiz_attempts} qa
LEFT JOIN {question_sessions} qns ON (qns.attemptid = qa.uniqueid)
LEFT JOIN {question_states} qs ON (qns.newgraded = qs.id AND qs.event IN (".QUESTION_EVENTS_GRADED."))
WHERE " .
......@@ -135,7 +135,7 @@ function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){
$params = array($quiz->id);
list($u_sql, $u_params) = $DB->get_in_or_equal($userids);
list($q_sql, $q_params) = $DB->get_in_or_equal($questionids);
$params = array_merge($params, $u_params, $q_params);
$sql = "SELECT qs.question, COUNT(1) AS totalattempts,
SUM(CASE WHEN (qs.event IN(".QUESTION_EVENTS_GRADED.")) THEN 1 ELSE 0 END) AS gradedattempts
......@@ -382,4 +382,4 @@ function quiz_report_list($context){
return $reportlist;
}
?>
<?php // $Id$
<?php
/**
* This script lists student attempts and responses
*
......@@ -55,7 +55,7 @@ class quiz_responses_report extends quiz_default_report {
$reporturl = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_select($quiz);
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
......@@ -131,7 +131,7 @@ class quiz_responses_report extends quiz_default_report {
$table->is_downloading($download, get_string('reportresponses','quiz_responses'),
"$COURSE->shortname ".format_string($quiz->name,true));
if (!$table->is_downloading()) {
// Only print headers if not asked to download data
$PAGE->requires->css('mod/quiz/report/responses/styles.css');
$this->print_header_and_tabs($cm, $course, $quiz, 'responses', '');
......@@ -170,12 +170,12 @@ class quiz_responses_report extends quiz_default_report {
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
}
}
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$hasfeedback = quiz_has_feedback($quiz);
// Construct the SQL
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, ';
if ($qmsubselect) {
......@@ -185,17 +185,17 @@ class quiz_responses_report extends quiz_default_report {
" ELSE 0 " .
"END) AS gradedattempt, ";
}
$fields .='qa.uniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
' u.lastname, u.institution, u.department, u.email, u.picture, u.imagealt, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration, ' .
'qa.layout ';
// This part is the same for all cases - join users and quiz_attempts tables
$from = '{user} u ';
$from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid';
$params = array('quizid' => $quiz->id);
if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
......@@ -223,23 +223,23 @@ class quiz_responses_report extends quiz_default_report {
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
break;
}
$table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params);
$table->set_sql($fields, $from, $where, $params);
// Define table columns
$columns = array();
$headers = array();
if (!$table->is_downloading() && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
}
if (!$table->is_downloading() && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
......@@ -253,7 +253,7 @@ class quiz_responses_report extends quiz_default_report {
$columns[]= 'firstname';
$headers[]= get_string('firstname');
}
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
......@@ -270,14 +270,14 @@ class quiz_responses_report extends quiz_default_report {
$columns[]= 'timestart';
$headers[]= get_string('startedon', 'quiz');
$columns[]= 'timefinish';
$headers[]= get_string('timecompleted','quiz');
$columns[]= 'duration';
$headers[]= get_string('attemptduration', 'quiz');
}
if ($showgrades) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade);
......@@ -287,7 +287,7 @@ class quiz_responses_report extends quiz_default_report {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
// we want to display responses for all questions
foreach ($questions as $id => $question) {
// Ignore questions of zero length
......@@ -295,36 +295,36 @@ class quiz_responses_report extends quiz_default_report {
$headers[] = '#'.$question->number;
$question->formattedname = strip_tags(format_string($question->name));
}
// Load the question type specific information
if (!get_question_options($questions)) {
print_error('cannotloadoptions', 'quiz_responses');
}
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'concattedid');
// Set up the table
$table->define_baseurl($reporturl->out(false, $displayoptions));
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
$table->no_sorting('feedbacktext');
$table->column_class('picture', 'picture');
$table->column_class('lastname', 'bold');
$table->column_class('firstname', 'bold');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
$table->set_attribute('id', 'attempts');
$table->out($pagesize, true);
}
return true;
......@@ -333,4 +333,4 @@ class quiz_responses_report extends quiz_default_report {
}
?>
<?php // $Id$
<?php
define ('QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY', 150);
class quiz_report_responses_table extends table_sql {
......@@ -149,10 +149,10 @@ class quiz_report_responses_table extends table_sql {
} else {
return '-';
}
$question = $this->questions[$questionid];
restore_question_state($question, $stateforqinattempt);
if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){
$formathtml = true;
} else {
......@@ -182,7 +182,7 @@ class quiz_report_responses_table extends table_sql {
} else {
return '';
}
} else {
return $summary;
}
......@@ -241,4 +241,4 @@ class quiz_report_responses_table extends table_sql {
}
}
}
?>
<?php // $Id$
<?php
require_once "$CFG->libdir/formslib.php";
class mod_quiz_report_responses_settings extends moodleform {
......@@ -44,4 +44,3 @@ class mod_quiz_report_responses_settings extends moodleform {
$this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview'));
}
}
?>
\ No newline at end of file
......@@ -25,21 +25,21 @@ class question_reportlib_test extends UnitTestCase {
$object->response = '';