Skip to content

Commit e0d8b2e

Browse files
da_clouddjdevin
da_cloud
authored andcommitted
Issue #2843890 by Da_Cloud: Coding Standards
1 parent 3844fc8 commit e0d8b2e

File tree

95 files changed

+1577
-1238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1577
-1238
lines changed

DEVELOPER.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ Hooks for interacting with a quiz:
1111

1212
## Developing new question types
1313

14-
You need to create a new module that extends the existing question type core. The truefalse or multichoice question types are good places to start.
14+
You need to create a new module that extends the existing question type core.
15+
The truefalse or multichoice question types are good places to start.
1516
Here are the steps:
1617

1718
1. Create a new module.
18-
2. Use your module's .install file to create the necessary tables for property and answer storage.
19+
2. Use your module's .install file to create the necessary tables for property
20+
and answer storage.
1921
3. Make sure you module implements `hook_quiz_question_info()`.
2022
4. Define classes that extend `QuizQuestion` and `QuizQuestionResponse`.
21-
For a complete example, see `multichoice.classes.inc` or `truefalse.classes.inc`.
23+
For a complete example, see `multichoice.classes.inc` or
24+
`truefalse.classes.inc`.

INSTALL.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
1. Copy the entire quiz/ folder into your modules directory.
44

5-
2. Log in to your site as an administrator, and go to the Administer >> Site building >> Modules
6-
section. Enable both the Quiz module, the Quiz Question module and at least one question type module
7-
(for example, Multichoice).
5+
2. Log in to your site as an administrator, and go to the Administer >> Site
6+
building >> Modules section. Enable both the Quiz module, the Quiz Question
7+
module and at least one question type module (for example, Multichoice).
88

99
## How to create a quiz
1010

1111
1. Create a basic quiz by going to Create content >> Quiz. You will have
1212
the opportunity to set many options if you would like.
1313

14-
2. Finally, add questions to the quiz by clicking the "Quiz" tab and then "Manage questions". Here you can create a new question, or use the question bank to add a previously used question.
14+
2. Finally, add questions to the quiz by clicking the "Quiz" tab and then
15+
"Manage questions". Here you can create a new question, or use the question
16+
bank to add a previously used question.
1517

1618
3. After adding questions, click the "Take" tab to take the Quiz!

README.md

+47-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
The Quiz module lets you create graded assessments in Drupal. A Quiz is given as a series of questions. Answers are then stored in the database. Scores and results are displayed during or after the quiz. Administrators can provide automatic or manual feedback. See all the features below! This module can be used as
1+
The Quiz module lets you create graded assessments in Drupal. A Quiz is given as
2+
a series of questions. Answers are then stored in the database. Scores and
3+
results are displayed during or after the quiz. Administrators can provide
4+
automatic or manual feedback. See all the features below! This module can be
5+
used as
26

37
* an object in a larger LMS, or a supplemental classroom activity
48
* a standalone activity (audio, video, rich text in questions/answers)
@@ -8,7 +12,8 @@ The Quiz module lets you create graded assessments in Drupal. A Quiz is given as
812
## Features
913

1014
* Extensive Views, Rules integration through Entity API
11-
* Integration with H5P making 20+ [content types](http://h5p.org/content-types-and-applications) available
15+
* Integration with H5P making 20+
16+
[content types](http://h5p.org/content-types-and-applications) available
1217
* OO Question API
1318
* Very configurable feedback times and options
1419
* Pre-attempt questionnaires (through Field API)
@@ -30,7 +35,8 @@ The Quiz module lets you create graded assessments in Drupal. A Quiz is given as
3035

3136
## Question types included
3237

33-
* H5P - 20 [H5P content types](http://h5p.org/content-types-and-applications) available
38+
* H5P - 20 [H5P content types](http://h5p.org/content-types-and-applications)
39+
available
3440
* 4.x - included
3541
* 5.x - https://www.drupal.org/project/quiz_h5p
3642
* True or false
@@ -40,27 +46,38 @@ The Quiz module lets you create graded assessments in Drupal. A Quiz is given as
4046
* Scale
4147
* Question directions
4248
* Matching
43-
* Drag and drop (with lines) - moved to https://www.drupal.org/project/quiz_ddlines
49+
* Drag and drop (with lines) - moved to
50+
https://www.drupal.org/project/quiz_ddlines
4451

4552
## Quiz addons
4653

47-
* [Charts](http://drupal.org/project/charts) - used by Quiz stats to render some useful data
48-
* [jQuery Countdown](http://drupal.org/project/jquery_countdown) - provides jQuery timer for timed quizzes
49-
* [Views Data Export](http://drupal.org/project/views_data_export) - export Quiz results and user answers
54+
* [Charts](http://drupal.org/project/charts) - used by Quiz stats to render
55+
some useful data
56+
* [jQuery Countdown](http://drupal.org/project/jquery_countdown) - provides
57+
jQuery timer for timed quizzes
58+
* [Views Data Export](http://drupal.org/project/views_data_export) - export
59+
Quiz results and user answers
5060

5161
## Other modules we like
5262

5363
* [H5P - HTML5 learning objects](https://www.drupal.org/project/h5p)
54-
* [Course](https://www.drupal.org/project/course) - put multiple quizzes together
55-
* [Certificate](https://www.drupal.org/project/certificate) - award a certificate after passing a Course/Quiz
64+
* [Course](https://www.drupal.org/project/course) - put multiple quizzes
65+
together
66+
* [Certificate](https://www.drupal.org/project/certificate) - award a
67+
certificate after passing a Course/Quiz
5668

57-
Check out the [Quiz affiliated modules wiki](http://groups.drupal.org/node/177684) to see a fuller list of modules that extend quiz.
69+
Check out the
70+
[Quiz affiliated modules wiki](http://groups.drupal.org/node/177684)
71+
to see a fuller list of modules that extend quiz.
5872

5973
## Upgrading from 7.x-4.x
6074

6175
If you do not have any custom question modules, an upgrade to 5.x is easy.
6276

63-
**Note:** There are core issues with MySQL 5.7, but only during the upgrade. See [here](https://www.drupal.org/node/2812685#comment-11702775) if you have to use MySQL 5.7 and Drupal 7. If you do have custom question modules, they may have to be updated slightly to work with the 5.x version.
77+
**Note:** There are core issues with MySQL 5.7, but only during the upgrade. See
78+
[here](https://www.drupal.org/node/2812685#comment-11702775) if you have to use
79+
MySQL 5.7 and Drupal 7. If you do have custom question modules, they may have to
80+
be updated slightly to work with the 5.x version.
6481

6582
## Roadmap
6683

@@ -75,16 +92,31 @@ If you do not have any custom question modules, an upgrade to 5.x is easy.
7592

7693
## Support
7794

78-
We have a big community supporting Quiz, and it's getting bigger! Let's make this the best assessment engine, ever. [IRC](https://drupal.org/irc), in #drupal-course (for Quiz, Course, Certificate module support) [IRC](https://drupal.org/irc), in #drupal-edu (general edu talk) [Drupal groups](https://groups.drupal.org/quiz) [The issue queue](https://www.drupal.org/project/issues/quiz)
95+
We have a big community supporting Quiz, and it's getting bigger! Let's make
96+
this the best assessment engine, ever. [IRC](https://drupal.org/irc),
97+
in #drupal-course (for Quiz, Course, Certificate module support)
98+
[IRC](https://drupal.org/irc), in #drupal-edu (general edu talk),
99+
[Drupal groups](https://groups.drupal.org/quiz),
100+
[The issue queue](https://www.drupal.org/project/issues/quiz)
79101

80102
## Help out
81103

82-
Please continue to help out with cleaning up the issue queue! https://drupal.org/node/2280951 Have a feature request? Please open an issue in the issue queue!
104+
Please continue to help out with cleaning up the issue queue!
105+
https://drupal.org/node/2280951 Have a feature request? Please open an issue in
106+
the issue queue!
83107

84108
## Drupal 8
85109

86-
The D7 version of this module is being cleaned up so that a migration/port to D8 will be easier.
110+
The D7 version of this module is being cleaned up so that a migration/port to
111+
D8 will be easier.
87112

88113
## Credits
89114

90-
Many users have contributed lots of feature requests and bug reports. Previous maintainers also deserve a lot of credit! Join the Quiz group at http://groups.drupal.org/quiz to get involved! **Quiz is currently being sponsored by:** djdevin@[DLC Solutions](http://www.dlc-solutions.com)/[EthosCE](http://www.ethosce.com) for the 7.x-5.x branch **Previous sponsors** [The e-learning company Amendor](http://amendor.com) [The Norwegian Centre for ICT in Education](http://iktsenteret.no/english) [Norwegian Centre for Integrated Care and Telemedicine](http://telemed.no/)
115+
Many users have contributed lots of feature requests and bug reports. Previous
116+
maintainers also deserve a lot of credit! Join the Quiz group at
117+
http://groups.drupal.org/quiz to get involved! **Quiz is currently being
118+
sponsored by:** djdevin@[DLC Solutions](http://www.dlc-solutions.com)/
119+
[EthosCE](http://www.ethosce.com) for the 7.x-5.x branch **Previous sponsors**
120+
[The e-learning company Amendor](http://amendor.com),
121+
[The Norwegian Centre for ICT in Education](http://iktsenteret.no/english),
122+
[Norwegian Centre for Integrated Care and Telemedicine](http://telemed.no/)

UPGRADING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ If you do not have any custom question modules, an upgrade to 5.x is easy.
1010
6. Verify that existing results work
1111
7. Done!
1212

13-
If you encounter any errors during update, please post them to https://www.drupal.org/project/issues/quiz
13+
If you encounter any errors during update, please post them to
14+
https://www.drupal.org/project/issues/quiz

includes/Quiz.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
class Quiz extends Entity {
44

5-
}
5+
}

includes/QuizMetadataController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizMetadataController extends EntityDefaultMetadataController {
44

5-
function entityPropertyInfo() {
5+
public function entityPropertyInfo() {
66
$info = parent::entityPropertyInfo();
77

88
$info['node']['properties']['quiz']['label'] = t('Quiz');

includes/QuizQuestionController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
class QuizQuestionController extends EntityAPIController {
44

5-
}
5+
}

includes/QuizQuestionMetadataController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizQuestionMetadataController extends EntityDefaultMetadataController {
44

5-
function entityPropertyInfo() {
5+
public function entityPropertyInfo() {
66
$info = parent::entityPropertyInfo();
77

88
$info['quiz_question']['properties']['nid']['type'] = 'node';

includes/QuizQuestionRelationship.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
class QuizQuestionRelationship extends Entity {
44

5-
}
5+
}

includes/QuizQuestionRelationshipController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
class QuizQuestionRelationshipController extends EntityAPIController {
44

5-
}
5+
}

includes/QuizQuestionRelationshipMetadataController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizQuestionRelationshipMetadataController extends EntityDefaultMetadataController {
44

5-
function entityPropertyInfo() {
5+
public function entityPropertyInfo() {
66
$info = parent::entityPropertyInfo();
77

88
$info['quiz_question_relationship']['properties']['child_nid']['type'] = 'node';

includes/QuizResult.class.inc

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class QuizResult extends Entity {
99
*
1010
* @return QuizResultAnswer[]
1111
*/
12-
function getLayout() {
12+
public function getLayout() {
1313
$layouts = drupal_static('quiz_result_layout', array());
1414

1515
if (!isset($layouts[$this->identifier()])) {
@@ -58,7 +58,10 @@ class QuizResult extends Entity {
5858
$quiz = node_load($this->nid, $this->vid);
5959
$user = user_load($this->uid);
6060

61-
return t('@user\'s @quiz result in "@title"', array('@user' => format_username($user), '@quiz' => QUIZ_NAME, '@title' => $quiz->title));
61+
return t('@user\'s @quiz result in "@title"', array(
62+
'@user' => format_username($user),
63+
'@quiz' => QUIZ_NAME, '@title' => $quiz->title,
64+
));
6265
}
6366

6467
}

includes/QuizResultAnswerMetadataController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizResultAnswerMetadataController extends EntityDefaultMetadataController {
44

5-
function entityPropertyInfo() {
5+
public function entityPropertyInfo() {
66
$info = parent::entityPropertyInfo();
77

88
$info['quiz_result_answer']['properties']['result_id']['type'] = 'quiz_result';

includes/QuizResultController.class.inc

+13-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizResultController extends EntityAPIController {
44

5-
function delete($ids, \DatabaseTransaction $transaction = NULL) {
5+
public function delete($ids, \DatabaseTransaction $transaction = NULL) {
66
foreach ($ids as $result_id) {
77
// Fire the question types' implementations of question attempts deletion.
88
$sql = 'SELECT result_id, question_nid, question_vid FROM {quiz_node_results_answers}
@@ -27,9 +27,10 @@ class QuizResultController extends EntityAPIController {
2727
*
2828
* @param type $entity
2929
* @param \DatabaseTransaction $transaction
30-
* @return boolean
30+
*
31+
* @return bool
3132
*/
32-
function save($entity, \DatabaseTransaction $transaction = NULL) {
33+
public function save($entity, \DatabaseTransaction $transaction = NULL) {
3334
if (empty($entity->time_start)) {
3435
$entity->time_start = REQUEST_TIME;
3536
}
@@ -56,8 +57,6 @@ class QuizResultController extends EntityAPIController {
5657
}
5758
}
5859

59-
60-
6160
// Save the Quiz result.
6261
parent::save($entity, $transaction);
6362

@@ -68,7 +67,6 @@ class QuizResultController extends EntityAPIController {
6867
// Call @deprecated hook_quiz_begin().
6968
module_invoke_all('quiz_begin', $quiz, $entity->result_id);
7069

71-
7270
// Create question list.
7371
$questions = quiz_build_question_list($quiz);
7472
if ($questions === FALSE) {
@@ -97,9 +95,9 @@ class QuizResultController extends EntityAPIController {
9795
}
9896

9997
if (!empty($entity->build_on_last)) {
100-
// Build on the last attempt the user took. If this quiz has build on last
101-
// attempt set, we need to search for a previous attempt with the same
102-
// version of the current quiz.
98+
// Build on the last attempt the user took. If this quiz has build on
99+
// last attempt set, we need to search for a previous attempt with the
100+
// same version of the current quiz.
103101
$quiz_result_old = self::findOldResult($entity);
104102
// Now clone the answers on top of the new result.
105103
quiz_clone_quiz_result($quiz_result_old, $entity);
@@ -114,7 +112,7 @@ class QuizResultController extends EntityAPIController {
114112
* will return the first completed result found.
115113
*/
116114
public static function findOldResult($quiz_result) {
117-
$efq = new EntityFieldQuery;
115+
$efq = new EntityFieldQuery();
118116
$result = $efq->entityCondition('entity_type', 'quiz_result')
119117
->propertyCondition('uid', $quiz_result->uid)
120118
->propertyCondition('nid', $quiz_result->nid)
@@ -156,10 +154,13 @@ class QuizResultController extends EntityAPIController {
156154
// Loop through all the questions and get their feedback.
157155
$question_node = node_load($question['nid'], $question['vid']);
158156

159-
160157
$instance = _quiz_question_response_get_instance($entity->result_id, $question_node);
161158
if ($instance->getQuizQuestion()->hasFeedback()) {
162-
$qras = entity_load('quiz_result_answer', FALSE, array('result_id' => $entity->result_id, 'question_nid' => $question_node->nid, 'question_vid' => $question_node->vid));
159+
$qras = entity_load('quiz_result_answer', FALSE, array(
160+
'result_id' => $entity->result_id,
161+
'question_nid' => $question_node->nid,
162+
'question_vid' => $question_node->vid,
163+
));
163164
$qra = reset($qras);
164165

165166
$feedback = $qra->view();

includes/QuizResultMetadataController.class.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class QuizResultMetadataController extends EntityDefaultMetadataController {
44

5-
function entityPropertyInfo() {
5+
public function entityPropertyInfo() {
66
$info = parent::entityPropertyInfo();
77

88
$info['quiz_result']['properties']['nid']['type'] = 'node';

includes/views/handlers/quiz_views_handler_field_quiz_question_result_answer.inc

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class quiz_views_handler_field_quiz_question_result_answer extends views_handler
55
/**
66
* Working with node table, adding active credit types to it.
77
*/
8-
function construct() {
8+
public function construct() {
99
parent::construct();
1010
$this->additional_fields['result_id'] = array(
1111
'table' => 'quiz_node_results',
@@ -16,12 +16,12 @@ class quiz_views_handler_field_quiz_question_result_answer extends views_handler
1616
/**
1717
* Add fields, alias.
1818
*/
19-
function query() {
19+
public function query() {
2020
$this->add_additional_fields();
2121
$this->field_alias = $this->aliases['result_id'];
2222
}
2323

24-
function option_definition() {
24+
public function option_definition() {
2525
$options = parent::option_definition();
2626

2727
$options['question_nid'] = array(
@@ -36,7 +36,7 @@ class quiz_views_handler_field_quiz_question_result_answer extends views_handler
3636
return $options;
3737
}
3838

39-
function pre_render(&$values) {
39+
public function pre_render(&$values) {
4040
$this->items = array();
4141

4242
$result_ids = array();
@@ -62,7 +62,7 @@ class quiz_views_handler_field_quiz_question_result_answer extends views_handler
6262
}
6363
}
6464

65-
function render_item($count, $item) {
65+
public function render_item($count, $item) {
6666
return parent::render_items($item);
6767
}
6868

includes/views/handlers/quiz_views_handler_filter_quiz_question.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66
class quiz_views_handler_filter_quiz_question extends views_handler_filter_boolean_operator {
77

8-
function query() {
8+
public function query() {
99
$this->ensure_my_table();
1010
$field = "$this->table_alias.$this->real_field";
1111
$types = array_keys(quiz_get_question_types());
1212
$in = $this->value ? 'IN' : 'NOT IN';
1313
$this->query->add_where($this->options['group'], db_and()->condition($field, $types, $in));
1414
}
1515

16-
function get_value_options() {
16+
public function get_value_options() {
1717
$this->value_options = array(
1818
1 => t('Yes'),
1919
0 => t('No'),

includes/views/quiz.views.inc

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/**
44
* @file
55
* This file provides metadata to the Views 2 API for views integration.
6-
*
76
*/
87

98
/**

0 commit comments

Comments
 (0)