Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quiz-3218427
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
quiz-3218427
Commits
ce231e67
Commit
ce231e67
authored
15 years ago
by
Sam Boyer
Browse files
Options
Downloads
Patches
Plain Diff
Initial attempt at field that performs score aggregation.
parent
bba5fee4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/views/handlers/quiz_views_handler_field_score_aggregate.inc
+38
-0
38 additions, 0 deletions
...ews/handlers/quiz_views_handler_field_score_aggregate.inc
includes/views/quiz.views.inc
+12
-0
12 additions, 0 deletions
includes/views/quiz.views.inc
with
50 additions
and
0 deletions
includes/views/handlers/quiz_views_handler_field_score_aggregate.inc
0 → 100644
+
38
−
0
View file @
ce231e67
<?php
// $Id$
class
quiz_views_handler_field_score_aggregate
extends
views_handler_field_numeric
{
function
construct
()
{
parent
::
construct
();
// This will have to change to be set by options if the methods are ever expanded
$this
->
group_field
=
$this
->
definition
[
'group field'
];
}
function
option_definition
()
{
$options
=
parent
::
option_definition
();
return
$options
;
}
function
query
()
{
$this
->
ensure_my_table
();
// $this->add_additional_fields();
// $results_field_alias = $this->additional_fields['qnr_score']['field'];
dsm
(
$this
);
// $results_table = $this->query->get_table_info($this->additional_fields['qnr_score']['table']);
$this
->
query
->
add_field
(
$this
->
table_alias
,
$this
->
group_field
);
$this
->
field_alias
=
$this
->
query
->
add_field
(
NULL
,
"AVERAGE(
$this->table_alias
.
$this->real_field
)"
,
$results_table
[
'alias'
]
.
'__average'
,
array
(
'aggregate'
=>
TRUE
)
);
$this
->
query
->
add_groupby
(
"
$this->table_alias
.
$this->group_field
"
);
// nid is OK for average. Others maybe not so much
// $base_join = $this->get_join_data($this->table_alias, $this->base_table);
// $results_join = $this->get_join_data($this->results_table['alias'], $this->base_table);
//
// $this->add_relationship($this->table_alias . '__join', $this->get_join_data($this->table_alias, $this->base_table), $this->base_table);
// $this->add_relationship($this->table_alias . '__join', $results_join, $this->base_table, $this->table);
dsm
(
$this
);
dsm
(
$this
->
query
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
includes/views/quiz.views.inc
+
12
−
0
View file @
ce231e67
...
...
@@ -22,6 +22,9 @@ function quiz_views_handlers() {
'quiz_views_handler_field_user_quiz_state'
=>
array
(
'parent'
=>
'views_handler_field'
,
),
'quiz_views_handler_field_score_aggregate'
=>
array
(
'parent'
=>
'views_handler_field_numeric'
,
),
// Filters
'quiz_views_handler_filter_question_status'
=>
array
(
'parent'
=>
'views_handler_filter_in_operator'
,
...
...
@@ -595,6 +598,15 @@ function quiz_views_data() {
),
'sort'
=>
array
(
'handler'
=>
'views_handler_sort'
),
),
'score_aggregate'
=>
array
(
'title'
=>
t
(
'Score Aggregations'
),
'help'
=>
t
(
'Aggregate scores on quizzes using a variety of different algorithms.'
),
'real field'
=>
'score'
,
'field'
=>
array
(
'handler'
=>
'quiz_views_handler_field_score_aggregate'
,
'group field'
=>
'nid'
,
),
),
'quiz_state'
=>
array
(
'title'
=>
t
(
'Quiz State'
),
'help'
=>
t
(
'The state of the quiz for the provided user. Calculated on the fly; can be "Finished," "In Progress," or "Not Started".'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment