Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
768a7588
Commit
768a7588
authored
Apr 04, 2012
by
Tim Hunt
Browse files
MDL-32322 quiz reports: Appease the great god codechecker.
parent
90fbad64
Changes
16
Hide whitespace changes
Inline
Side-by-side
mod/quiz/report/attemptsreport.php
View file @
768a7588
...
...
@@ -118,15 +118,16 @@ abstract class quiz_attempt_report extends quiz_default_report {
*/
protected
function
validate_common_options
(
&
$attemptsmode
,
&
$pagesize
,
$course
,
$currentgroup
)
{
if
(
$currentgroup
)
{
//
d
efault for when a group is selected
//
D
efault for when a group is selected
.
if
(
$attemptsmode
===
null
||
$attemptsmode
==
QUIZ_REPORT_ATTEMPTS_ALL
)
{
$attemptsmode
=
QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH
;
}
}
else
if
(
!
$currentgroup
&&
$course
->
id
==
SITEID
)
{
//
f
orce report on front page to show all, unless a group is selected.
//
F
orce report on front page to show all, unless a group is selected.
$attemptsmode
=
QUIZ_REPORT_ATTEMPTS_ALL
;
}
else
if
(
$attemptsmode
===
null
)
{
//default
$attemptsmode
=
QUIZ_REPORT_ATTEMPTS_ALL
;
}
...
...
@@ -158,7 +159,7 @@ abstract class quiz_attempt_report extends quiz_default_report {
}
// When downloading, some extra fields are always displayed (because
// there's no space constraint) so do not include in extra-field list
// there's no space constraint) so do not include in extra-field list
.
$extrafields
=
get_extra_user_fields
(
$this
->
context
,
$table
->
is_downloading
()
?
array
(
'institution'
,
'department'
,
'email'
)
:
array
());
foreach
(
$extrafields
as
$field
)
{
...
...
mod/quiz/report/attemptsreport_table.php
View file @
768a7588
...
...
@@ -306,9 +306,9 @@ abstract class quiz_attempt_report_table extends table_sql {
// subtracting a larger unsigned int from a smaller one gave an error.
// Therefore, we avoid doing that. timefinish can be non-zero and less
// than timestart when you have two load-balanced servers with very
// badly synchronised clocks, and a student does a really quick attempt.
';
// badly synchronised clocks, and a student does a really quick attempt.
// This part is the same for all cases
- join
users and quiz_attempts tables
// This part is the same for all cases
. Join the
users and quiz_attempts tables
.
$from
=
"
\n
{
user
}
u"
;
$from
.
=
"
\n
LEFT JOIN
{
quiz_attempts
}
quiza ON
quiza.userid = u.id AND quiza.quiz = :quizid"
;
...
...
@@ -319,25 +319,25 @@ abstract class quiz_attempt_report_table extends table_sql {
}
switch
(
$this
->
attemptsmode
)
{
case
QUIZ_REPORT_ATTEMPTS_ALL
:
// Show all attempts, including students who are no longer in the course
// Show all attempts, including students who are no longer in the course
.
$where
=
'quiza.id IS NOT NULL AND quiza.preview = 0'
;
break
;
case
QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH
:
// Show only students with attempts
// Show only students with attempts
.
list
(
$usql
,
$uparams
)
=
$DB
->
get_in_or_equal
(
$reportstudents
,
SQL_PARAMS_NAMED
,
'u'
);
$params
+=
$uparams
;
$where
=
"u.id
$usql
AND quiza.preview = 0 AND quiza.id IS NOT NULL"
;
break
;
case
QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO
:
// Show only students without attempts
// Show only students without attempts
.
list
(
$usql
,
$uparams
)
=
$DB
->
get_in_or_equal
(
$reportstudents
,
SQL_PARAMS_NAMED
,
'u'
);
$params
+=
$uparams
;
$where
=
"u.id
$usql
AND quiza.id IS NULL"
;
break
;
case
QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS
:
// Show all students with or without attempts
// Show all students with or without attempts
.
list
(
$usql
,
$uparams
)
=
$DB
->
get_in_or_equal
(
$reportstudents
,
SQL_PARAMS_NAMED
,
'u'
);
$params
+=
$uparams
;
...
...
@@ -464,7 +464,8 @@ abstract class quiz_attempt_report_table extends table_sql {
echo
' '
;
$this
->
submit_buttons
();
echo
'</div>'
;
// Close form
// Close the form.
echo
'</div>'
;
echo
'</form></div>'
;
}
...
...
mod/quiz/report/default.php
View file @
768a7588
...
...
@@ -63,7 +63,7 @@ abstract class quiz_default_report {
public
function
print_header_and_tabs
(
$cm
,
$course
,
$quiz
,
$reportmode
=
'overview'
)
{
global
$PAGE
,
$OUTPUT
;
// Print the page header
// Print the page header
.
$PAGE
->
set_title
(
format_string
(
$quiz
->
name
));
$PAGE
->
set_heading
(
$course
->
fullname
);
echo
$OUTPUT
->
header
();
...
...
mod/quiz/report/grading/report.php
View file @
768a7588
...
...
@@ -82,7 +82,7 @@ class quiz_grading_report extends quiz_default_report {
$this
->
viewoptions
[
'order'
]
=
$order
;
}
// Check permissions
// Check permissions
.
$this
->
context
=
context_module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/quiz:grade'
,
$this
->
context
);
$shownames
=
has_capability
(
'quiz/grading:viewstudentnames'
,
$this
->
context
);
...
...
@@ -269,7 +269,7 @@ class quiz_grading_report extends quiz_default_report {
global
$OUTPUT
;
if
(
$groupmode
=
groups_get_activity_groupmode
(
$this
->
cm
))
{
// Groups
are
being used
// Groups
is
being used
.
groups_print_activity_menu
(
$this
->
cm
,
$this
->
list_questions_url
());
}
...
...
mod/quiz/report/overview/db/upgrade.php
View file @
768a7588
...
...
@@ -35,9 +35,8 @@ function xmldb_quiz_overview_upgrade($oldversion) {
$dbman
=
$DB
->
get_manager
();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.2.0 release upgrade line.
// Put any upgrade step following this.
return
true
;
}
mod/quiz/report/overview/overviewgraph.php
View file @
768a7588
...
...
@@ -40,7 +40,7 @@ $modcontext = context_module::instance($cm->id);
require_capability
(
'mod/quiz:viewreports'
,
$modcontext
);
if
(
$groupid
&&
$groupmode
=
groups_get_activity_groupmode
(
$cm
))
{
// Groups are being used
// Groups are being used
.
$groups
=
groups_get_activity_allowed_groups
(
$cm
);
if
(
!
array_key_exists
(
$groupid
,
$groups
))
{
print_error
(
'errorinvalidgroup'
,
'group'
,
null
,
$groupid
);
...
...
@@ -65,16 +65,16 @@ $line->parameter['y_label_angle'] = 90;
$line
->
parameter
[
'x_label_angle'
]
=
0
;
$line
->
parameter
[
'x_axis_angle'
]
=
60
;
//following two lines seem to silence notice warnings from graphlib.php
//
The
following two lines seem to silence notice warnings from graphlib.php
.
$line
->
y_tick_labels
=
null
;
$line
->
offset_relation
=
null
;
// will make size > 1 to get overlap effect when showing groups
//
We
will make size > 1 to get
an
overlap effect when showing groups
.
$line
->
parameter
[
'bar_size'
]
=
1
;
//
d
on't forget to increase spacing so that graph doesn't become one big block of colour
//
D
on't forget to increase spacing so that graph doesn't become one big block of colour
.
$line
->
parameter
[
'bar_spacing'
]
=
10
;
//
p
ick a sensible number of bands depending on quiz maximum grade.
//
P
ick a sensible number of bands depending on quiz maximum grade.
$bands
=
$quiz
->
grade
;
while
(
$bands
>
20
||
$bands
<=
10
)
{
if
(
$bands
>
50
)
{
...
...
@@ -109,11 +109,11 @@ $line->y_data['allusers'] = quiz_report_grade_bands($bandwidth, $bands, $quizid,
$line
->
y_order
=
array
(
'allusers'
);
$ymax
=
max
(
$line
->
y_data
[
'allusers'
]);
$line
->
parameter
[
'y_min_left'
]
=
0
;
// start at 0
$line
->
parameter
[
'y_min_left'
]
=
0
;
$line
->
parameter
[
'y_max_left'
]
=
$ymax
;
$line
->
parameter
[
'y_decimal_left'
]
=
0
;
// 2 decimal places for y axis.
$line
->
parameter
[
'y_decimal_left'
]
=
0
;
//
p
ick a sensible number of gridlines depending on max value on graph.
//
P
ick a sensible number of gridlines depending on max value on graph.
$gridlines
=
$ymax
;
while
(
$gridlines
>=
10
)
{
if
(
$gridlines
>=
50
)
{
...
...
mod/quiz/report/overview/report.php
View file @
768a7588
...
...
@@ -169,18 +169,19 @@ class quiz_overview_report extends quiz_attempt_report {
// Start output.
if
(
!
$table
->
is_downloading
())
{
// Only print headers if not asked to download data
// Only print headers if not asked to download data
.
$this
->
print_header_and_tabs
(
$cm
,
$course
,
$quiz
,
'overview'
);
}
if
(
$groupmode
=
groups_get_activity_groupmode
(
$cm
))
{
// Groups are being used
if
(
$groupmode
=
groups_get_activity_groupmode
(
$cm
))
{
// Groups are being used, output the group selector if we are not downloading.
if
(
!
$table
->
is_downloading
())
{
groups_print_activity_menu
(
$cm
,
$reporturl
->
out
(
true
,
$displayoptions
));
}
}
// Print information on the number of existing attempts
if
(
!
$table
->
is_downloading
())
{
//
d
o not print notices when downloading
// Print information on the number of existing attempts
.
if
(
!
$table
->
is_downloading
())
{
//
D
o not print notices when downloading
.
if
(
$strattemptnum
=
quiz_num_attempt_summary
(
$quiz
,
$cm
,
true
,
$currentgroup
))
{
echo
'<div class="quizattemptcounts">'
.
$strattemptnum
.
'</div>'
;
}
...
...
@@ -196,13 +197,13 @@ class quiz_overview_report extends quiz_attempt_report {
echo
$OUTPUT
->
notification
(
get_string
(
'nostudentsingroup'
));
}
// Print display options
// Print display options
.
$mform
->
display
();
}
$hasstudents
=
$students
&&
(
!
$currentgroup
||
$groupstudents
);
if
(
$hasquestions
&&
(
$hasstudents
||
(
$attemptsmode
==
QUIZ_REPORT_ATTEMPTS_ALL
)))
{
// Construct the SQL
// Construct the SQL
.
$fields
=
$DB
->
sql_concat
(
'u.id'
,
"'#'"
,
'COALESCE(quiza.attempt, 0)'
)
.
' AS uniqueid, '
;
if
(
$qmsubselect
)
{
...
...
@@ -233,7 +234,7 @@ class quiz_overview_report extends quiz_attempt_report {
$table
->
set_sql
(
$fields
,
$from
,
$where
,
$params
);
if
(
!
$table
->
is_downloading
())
{
//
R
egrade buttons
//
Output the r
egrade buttons
.
if
(
has_capability
(
'mod/quiz:regrade'
,
$this
->
context
))
{
$regradesneeded
=
$this
->
count_question_attempts_needing_regrade
(
$quiz
,
$groupstudents
);
...
...
@@ -273,14 +274,14 @@ class quiz_overview_report extends quiz_attempt_report {
echo
'</form>'
;
echo
'</div>'
;
}
// Print information on the grading method
// Print information on the grading method
.
if
(
$strattempthighlight
=
quiz_report_highlighting_grading_method
(
$quiz
,
$qmsubselect
,
$qmfilter
))
{
echo
'<div class="quizattemptcounts">'
.
$strattempthighlight
.
'</div>'
;
}
}
// Define table columns
// Define table columns
.
$columns
=
array
();
$headers
=
array
();
...
...
@@ -295,7 +296,7 @@ class quiz_overview_report extends quiz_attempt_report {
if
(
$detailedmarks
)
{
foreach
(
$questions
as
$slot
=>
$question
)
{
// Ignore questions of zero length
// Ignore questions of zero length
.
$columns
[]
=
'qsgrade'
.
$slot
;
$header
=
get_string
(
'qbrief'
,
'quiz'
,
$question
->
number
);
if
(
!
$table
->
is_downloading
())
{
...
...
@@ -466,7 +467,7 @@ class quiz_overview_report extends quiz_attempt_report {
$where
=
"quiza.quiz = ? AND quiza.preview = 0 AND qqr.regraded = 0"
;
$params
=
array
(
$quiz
->
id
);
// Fetch all attempts that need regrading
// Fetch all attempts that need regrading
.
if
(
$groupstudents
)
{
list
(
$usql
,
$uparams
)
=
$DB
->
get_in_or_equal
(
$groupstudents
);
$where
.
=
" AND quiza.userid
$usql
"
;
...
...
@@ -551,7 +552,7 @@ class quiz_overview_report extends quiz_attempt_report {
protected
function
clear_regrade_table
(
$quiz
,
$groupstudents
)
{
global
$DB
;
// Fetch all attempts that need regrading
// Fetch all attempts that need regrading
.
$where
=
''
;
$params
=
array
();
if
(
$groupstudents
)
{
...
...
mod/quiz/report/reportlib.php
View file @
768a7588
...
...
@@ -141,7 +141,8 @@ WHERE
* empty string if all attempts contribute to final grade.
*/
function
quiz_report_qm_filter_select
(
$quiz
,
$quizattemptsalias
=
'quiza'
)
{
if
(
$quiz
->
attempts
==
1
)
{
// Only one attempt allowed on this quiz
if
(
$quiz
->
attempts
==
1
)
{
// This quiz only allows one attempt.
return
''
;
}
...
...
@@ -217,13 +218,13 @@ ORDER BY
$data
=
$DB
->
get_records_sql_menu
(
$sql
,
$params
);
//need to create array elements with values 0 at indexes where there is no element
//
We
need to create array elements with values 0 at indexes where there is no element
.
$data
=
$data
+
array_fill
(
0
,
$bands
+
1
,
0
);
ksort
(
$data
);
//
p
lace the maximum (prefect grade) into the last band i.e. make last
//band for example 9 <= g <=10 (where 10 is the perfect grade) rather than
//just 9 <= g <10.
//
P
lace the maximum (prefect grade) into the last band i.e. make last
//
band for example 9 <= g <=10 (where 10 is the perfect grade) rather than
//
just 9 <= g <10.
$data
[
$bands
-
1
]
+=
$data
[
$bands
];
unset
(
$data
[
$bands
]);
...
...
@@ -326,7 +327,7 @@ function quiz_report_list($context) {
$reports
=
$DB
->
get_records
(
'quiz_reports'
,
null
,
'displayorder DESC'
,
'name, capability'
);
$reportdirs
=
get_plugin_list
(
'quiz'
);
// Order the reports tab in descending order of displayorder
// Order the reports tab in descending order of displayorder
.
$reportcaps
=
array
();
foreach
(
$reports
as
$key
=>
$report
)
{
if
(
array_key_exists
(
$report
->
name
,
$reportdirs
))
{
...
...
@@ -334,7 +335,7 @@ function quiz_report_list($context) {
}
}
// Add any other reports, which are on disc but not in the DB, on the end
// Add any other reports, which are on disc but not in the DB, on the end
.
foreach
(
$reportdirs
as
$reportname
=>
$notused
)
{
if
(
!
isset
(
$reportcaps
[
$reportname
]))
{
$reportcaps
[
$reportname
]
=
null
;
...
...
mod/quiz/report/responses/report.php
View file @
768a7588
...
...
@@ -150,18 +150,20 @@ class quiz_responses_report extends quiz_attempt_report {
}
if
(
!
$table
->
is_downloading
())
{
// Only print headers if not asked to download data
// Only print headers if not asked to download data
.
$this
->
print_header_and_tabs
(
$cm
,
$course
,
$quiz
,
'responses'
);
}
if
(
$groupmode
=
groups_get_activity_groupmode
(
$cm
))
{
// Groups are being used
if
(
$groupmode
=
groups_get_activity_groupmode
(
$cm
))
{
// Groups are being used, so output the group selector if we are not downloading.
if
(
!
$table
->
is_downloading
())
{
groups_print_activity_menu
(
$cm
,
$reporturl
->
out
(
true
,
$displayoptions
));
}
}
// Print information on the number of existing attempts
if
(
!
$table
->
is_downloading
())
{
//do not print notices when downloading
// 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
))
{
echo
'<div class="quizattemptcounts">'
.
$strattemptnum
.
'</div>'
;
}
...
...
@@ -177,14 +179,15 @@ class quiz_responses_report extends quiz_attempt_report {
echo
$OUTPUT
->
notification
(
get_string
(
'nostudentsingroup'
));
}
// Print display options
// Print
the
display options
.
$mform
->
display
();
}
$hasstudents
=
$students
&&
(
!
$currentgroup
||
$groupstudents
);
if
(
$hasquestions
&&
(
$hasstudents
||
$attemptsmode
==
QUIZ_REPORT_ATTEMPTS_ALL
))
{
// Print information on the grading method and whether we are displaying
if
(
!
$table
->
is_downloading
())
{
//do not print notices when downloading
// Print information on the grading method and whether we are displaying.
if
(
!
$table
->
is_downloading
())
{
// Do not print notices when downloading.
if
(
$strattempthighlight
=
quiz_report_highlighting_grading_method
(
$quiz
,
$qmsubselect
,
$qmfilter
))
{
echo
'<div class="quizattemptcounts">'
.
$strattempthighlight
.
'</div>'
;
...
...
@@ -197,7 +200,7 @@ class quiz_responses_report extends quiz_attempt_report {
$table
->
set_sql
(
$fields
,
$from
,
$where
,
$params
);
// Define table columns
// Define table columns
.
$columns
=
array
();
$headers
=
array
();
...
...
@@ -233,7 +236,7 @@ class quiz_responses_report extends quiz_attempt_report {
$table
->
define_headers
(
$headers
);
$table
->
sortable
(
true
,
'uniqueid'
);
// Set up the table
// Set up the table
.
$table
->
define_baseurl
(
$reporturl
->
out
(
true
,
$displayoptions
));
$this
->
configure_user_columns
(
$table
);
...
...
mod/quiz/report/simpletest/testreportlib.php
View file @
768a7588
...
...
@@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die();
global
$CFG
;
require_once
(
$CFG
->
dirroot
.
'/mod/quiz/report/reportlib.php'
);
// Include the code to test
require_once
(
$CFG
->
dirroot
.
'/mod/quiz/report/reportlib.php'
);
/**
...
...
mod/quiz/report/statistics/db/upgrade.php
View file @
768a7588
...
...
@@ -34,9 +34,8 @@ function xmldb_quiz_statistics_upgrade($oldversion) {
$dbman
=
$DB
->
get_manager
();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
// Moodle v2.2.0 release upgrade line.
// Put any upgrade step following this.
return
true
;
}
...
...
mod/quiz/report/statistics/qstats.php
View file @
768a7588
...
...
@@ -202,7 +202,7 @@ class quiz_statistics_question_stats {
// This cannot be a foreach loop because we need to have both
// $question and $nextquestion available, but apart from that it is
// foreach ($this->questions as $qid => $question)
{
// foreach ($this->questions as $qid => $question)
.
reset
(
$this
->
questions
);
while
(
list
(
$slot
,
$question
)
=
each
(
$this
->
questions
))
{
$nextquestion
=
current
(
$this
->
questions
);
...
...
@@ -219,7 +219,7 @@ class quiz_statistics_question_stats {
$nextrandomselectorstring
=
$nextquestion
->
category
.
'/'
.
$nextquestion
->
questiontext
;
if
(
$randomselectorstring
==
$nextrandomselectorstring
)
{
continue
;
// Next loop iteration
continue
;
// Next loop iteration
.
}
}
if
(
isset
(
$this
->
randomselectors
[
$randomselectorstring
]))
{
...
...
@@ -229,7 +229,7 @@ class quiz_statistics_question_stats {
}
}
// Go through the records one more time
// Go through the records one more time
.
foreach
(
$this
->
lateststeps
as
$step
)
{
$this
->
secondary_steps_walker
(
$step
,
$this
->
questions
[
$step
->
slot
]
->
_stats
);
...
...
mod/quiz/report/statistics/report.php
View file @
768a7588
...
...
@@ -42,7 +42,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/statistics/responseanalysis.php')
*/
class
quiz_statistics_report
extends
quiz_default_report
{
/** @var integer Time after which statistics are automatically recomputed. */
const
TIME_TO_CACHE_STATS
=
900
;
// 15 minutes
const
TIME_TO_CACHE_STATS
=
900
;
// 15 minutes
.
/** @var object instance of table class used for main questions stats table. */
protected
$table
;
...
...
@@ -83,7 +83,7 @@ class quiz_statistics_report extends quiz_default_report {
$useallattempts
=
get_user_preferences
(
'quiz_report_statistics_useallattempts'
,
0
);
}
// Find out current groups mode
// Find out current groups mode
.
$currentgroup
=
$this
->
get_current_group
(
$cm
,
$course
,
$this
->
context
);
$nostudentsingroup
=
false
;
// True if a group is selected and there is no one in it.
if
(
empty
(
$currentgroup
))
{
...
...
@@ -95,7 +95,7 @@ class quiz_statistics_report extends quiz_default_report {
$nostudentsingroup
=
true
;
}
else
{
// All users who can attempt quizzes and who are in the currently selected group
// All users who can attempt quizzes and who are in the currently selected group
.
$groupstudents
=
get_users_by_capability
(
$this
->
context
,
array
(
'mod/quiz:reviewmyattempts'
,
'mod/quiz:attempt'
),
''
,
''
,
''
,
''
,
$currentgroup
,
''
,
false
);
...
...
@@ -505,7 +505,7 @@ class quiz_statistics_report extends quiz_default_report {
$formattedvalue
=
quiz_format_grade
(
$quiz
,
$value
)
.
'%'
;
break
;
case
'number_format'
:
//
+ 2
decimal places, since not a percentage,
//
2 extra
decimal places, since not a percentage,
// and we want the same number of sig figs.
$formattedvalue
=
format_float
(
$value
,
$quiz
->
decimalpoints
+
2
);
break
;
...
...
@@ -638,7 +638,7 @@ class quiz_statistics_report extends quiz_default_report {
// Calculating MEAN of marks for all attempts by students
// http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
//
#Calculating_MEAN_of_grades_for_all_attempts_by_students
// #Calculating_MEAN_of_grades_for_all_attempts_by_students
.
if
(
$nostudentsingroup
)
{
return
$this
->
get_emtpy_stats
(
$questions
);
}
...
...
@@ -704,9 +704,9 @@ class quiz_statistics_report extends quiz_default_report {
list
(
$fromqa
,
$whereqa
,
$qaparams
)
=
quiz_statistics_attempts_sql
(
$quizid
,
$currentgroup
,
$groupstudents
,
$useallattempts
);
// Median
// Median
...
if
(
$s
%
2
==
0
)
{
//even number of attempts
//
An
even number of attempts
.
$limitoffset
=
$s
/
2
-
1
;
$limit
=
2
;
}
else
{
...
...
@@ -722,8 +722,8 @@ class quiz_statistics_report extends quiz_default_report {
$quizstats
->
median
=
array_sum
(
$medianmarks
)
/
count
(
$medianmarks
);
if
(
$s
>
1
)
{
//
f
etch sum of squared, cubed and power 4d
//differences between marks and mean mark
//
F
etch
the
sum of squared, cubed and power 4d
//
differences between marks and mean mark
.
$mean
=
$usingattempts
->
total
/
$s
;
$sql
=
"SELECT
SUM(POWER((quiza.sumgrades -
$mean
), 2)) AS power2,
...
...
@@ -735,16 +735,16 @@ class quiz_statistics_report extends quiz_default_report {
$powers
=
$DB
->
get_record_sql
(
$sql
,
$params
,
MUST_EXIST
);
// Standard_Deviation
// Standard_Deviation
:
// see http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
// #Standard_Deviation
// #Standard_Deviation
.
$quizstats
->
standarddeviation
=
sqrt
(
$powers
->
power2
/
(
$s
-
1
));
// Skewness
// Skewness
.
if
(
$s
>
2
)
{
//
s
ee http://docs.moodle.org/dev/
// Quiz_item_analysis_calculations_in_practise#Skewness_and_Kurtosis
//
S
ee http://docs.moodle.org/dev/
// Quiz_item_analysis_calculations_in_practise#Skewness_and_Kurtosis
.
$m2
=
$powers
->
power2
/
$s
;
$m3
=
$powers
->
power3
/
$s
;
$m4
=
$powers
->
power4
/
$s
;
...
...
@@ -756,7 +756,7 @@ class quiz_statistics_report extends quiz_default_report {
}
}
// Kurtosis
// Kurtosis
.
if
(
$s
>
3
)
{
$k4
=
$s
*
$s
*
(((
$s
+
1
)
*
$m4
)
-
(
3
*
(
$s
-
1
)
*
$m2
*
$m2
))
/
((
$s
-
1
)
*
(
$s
-
2
)
*
(
$s
-
3
));
if
(
$k2
)
{
...
...
@@ -770,7 +770,7 @@ class quiz_statistics_report extends quiz_default_report {
$qstats
->
compute_statistics
();
if
(
$s
>
1
)
{
$p
=
count
(
$qstats
->
questions
);
// N
o
of positions
$p
=
count
(
$qstats
->
questions
);
// N
umber
of positions
.
if
(
$p
>
1
&&
isset
(
$k2
))
{
$quizstats
->
cic
=
(
100
*
$p
/
(
$p
-
1
))
*
(
1
-
(
$qstats
->
get_sum_of_mark_variance
())
/
$k2
);
...
...
mod/quiz/report/statistics/simpletest/test_qstats.php
View file @
768a7588
...
...
@@ -63,18 +63,18 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
public
function
test_qstats
()
{
global
$CFG
;
// Data is taken from randomly generated attempts data generated by
// contrib/tools/generators/qagenerator/
// contrib/tools/generators/qagenerator/
.
$steps
=
$this
->
get_records_from_csv
(
$CFG
->
dirroot
.
'/mod/quiz/report/statistics/simpletest/mdl_question_states.csv'
);
// Data is taken from questions mostly generated by
// contrib/tools/generators/generator.php
// contrib/tools/generators/generator.php
.
$questions
=
$this
->
get_records_from_csv
(
$CFG
->
dirroot
.
'/mod/quiz/report/statistics/simpletest/mdl_question.csv'
);
$this
->
qstats
=
new
testable_quiz_statistics_question_stats
(
$questions
,
22
,
10045.45455
);
$this
->
qstats
->
set_step_data
(
$steps
);
$this
->
qstats
->
compute_statistics
();
// Values expected are taken from contrib/tools/quiz_tools/stats.xls
// Values expected are taken from contrib/tools/quiz_tools/stats.xls
.
$facility
=
array
(
0
,
0
,
0
,
0
,
null
,
null
,
null
,
41.19318182
,
81.36363636
,
71.36363636
,
65.45454545
,
65.90909091
,
36.36363636
,
59.09090909
,
50
,
59.09090909
,
63.63636364
,
45.45454545
,
27.27272727
,
50
);
...
...
@@ -135,7 +135,8 @@ class quiz_statistics_question_stats_test extends UnitTestCase {
public
function
get_records_from_csv
(
$filename
)
{
$filecontents
=
file
(
$filename
,
FILE_IGNORE_NEW_LINES
);
$records
=
array
();
$keys
=
$this
->
get_fields_from_csv
(
array_shift
(
$filecontents
));
//first line is field names
// Skip the first line containing field names.
$keys
=
$this
->
get_fields_from_csv
(
array_shift
(
$filecontents
));
while
(
null
!==
(
$line
=
array_shift
(
$filecontents
)))
{
$data
=
$this
->
get_fields_from_csv
(
$line
);
$arraykey
=
reset
(
$data
);
...
...
mod/quiz/report/statistics/statistics_question_table.php
View file @
768a7588
...
...
@@ -68,7 +68,7 @@ class quiz_statistics_question_table extends flexible_table {
$this
->
collapsible
(
false
);
$this
->
set_attribute
(
'class'
,
'generaltable generalbox boxaligncenter'
);
// Define table columns
// Define
the
table columns
.
$columns
=
array
();
$headers
=
array
();
...
...
mod/quiz/report/statistics/statistics_table.php
View file @
768a7588
...
...
@@ -62,7 +62,7 @@ class quiz_statistics_table extends flexible_table {
$this
->
quiz
=
$quiz
;
$this
->
cmid
=
$cmid
;
// Define table columns
// Define
the
table columns
.
$columns
=
array
();
$headers
=
array
();
...
...
@@ -121,7 +121,7 @@ class quiz_statistics_table extends flexible_table {
$this
->
column_class
(
'discrimination_index'
,
'numcol'
);
$this
->
column_class
(
'discriminative_efficiency'
,
'numcol'
);
// Set up the table
// Set up the table
.
$this
->
define_baseurl
(
$reporturl
->
out
());
$this
->
collapsible
(
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment