Skip to content

Commit

Permalink
Adapted Frankenstyle naming for most classes and functions (excluding…
Browse files Browse the repository at this point in the history
… lib.php and locallib.php).
  • Loading branch information
Lukas Dürrenberge committed Nov 24, 2016
1 parent ae274eb commit 602a5ba
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 86 deletions.
4 changes: 2 additions & 2 deletions backup/moodle2/backup_studentquiz_activity_task.class.php
Expand Up @@ -35,7 +35,7 @@
* @copyright 2015 Your Name <your@email.adress>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_studentquiz_activity_task extends backup_activity_task {
class mod_studentquiz_backup_activity_task extends backup_activity_task {

/**
* No specific settings for this activity
Expand All @@ -47,7 +47,7 @@ protected function define_my_settings() {
* Defines a backup step to store the instance data in the studentquiz.xml file
*/
protected function define_my_steps() {
$this->add_step(new backup_studentquiz_activity_structure_step('studentquiz_structure', 'studentquiz.xml'));
$this->add_step(new mod_studentquiz_backup_activity_structure_step('studentquiz_structure', 'studentquiz.xml'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_studentquiz_stepslib.php
Expand Up @@ -33,7 +33,7 @@
* @copyright 2016 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_studentquiz_activity_structure_step extends backup_activity_structure_step {
class mod_studentquiz_backup_activity_structure_step extends backup_activity_structure_step {

/**
* Defines the backup structure of the module
Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/restore_studentquiz_activity_task.class.php
Expand Up @@ -37,7 +37,7 @@
* @copyright 2015 Your Name <your@email.adress>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_studentquiz_activity_task extends restore_activity_task {
class mod_studentquiz_restore_activity_task extends restore_activity_task {

/**
* Define (add) particular settings this activity can have
Expand All @@ -51,7 +51,7 @@ protected function define_my_settings() {
*/
protected function define_my_steps() {
// We have just one structure step here.
$this->add_step(new restore_studentquiz_activity_structure_step('studentquiz_structure', 'studentquiz.xml'));
$this->add_step(new mod_studentquiz_restore_activity_structure_step('studentquiz_structure', 'studentquiz.xml'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_studentquiz_stepslib.php
Expand Up @@ -33,7 +33,7 @@
* @copyright 2016 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_studentquiz_activity_structure_step extends restore_activity_structure_step {
class mod_studentquiz_restore_activity_structure_step extends restore_activity_structure_step {

/**
* Defines structure of path elements to be processed during the restore
Expand Down
Expand Up @@ -36,7 +36,7 @@
* @copyright 2016 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class student_quiz_condition extends \core_question\bank\search\category_condition {
class studentquiz_condition extends \core_question\bank\search\category_condition {

/**
* Called by question_bank_view to display the GUI for selecting a category
Expand Down
4 changes: 1 addition & 3 deletions classes/question/bank/question_bank_filter.php
Expand Up @@ -36,7 +36,7 @@
* @copyright 2016 HSR (http://www.hsr.ch)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class question_bank_filter_form extends moodleform {
class mod_studentquiz_question_bank_filter_form extends moodleform {

/**
* Filter fields of question bank
Expand Down Expand Up @@ -78,8 +78,6 @@ public function get_fields() {
* Defines forms elements
*/
public function definition() {
global $CFG;

$mform = $this->_form;
$mform->addElement('header', 'filtertab', get_string('filter', 'studentquiz'));
$mform->setExpanded('filtertab', false);
Expand Down
12 changes: 6 additions & 6 deletions classes/question/bank/studentquiz_bank_view.php
Expand Up @@ -103,7 +103,7 @@ public function set_fields() {
$this->fields[] = new \user_filter_number('comment', get_string('filter_label_comment', 'studentquiz'), true, 'comment');
$this->fields[] = new \user_filter_text('name', get_string('filter_label_question', 'studentquiz'), true, 'name');
$this->fields[] = new \user_filter_text('questiontext', 'Question content', true, 'questiontext');
if (is_anonym($this->cm->id) && !check_created_permission()) {
if (mod_studentquiz_is_anonym($this->cm->id) && !mod_studentquiz_check_created_permission()) {
$this->fields[] = new \user_filter_checkbox('createdby'
, get_string('filter_label_show_mine', 'studentquiz'), true, 'createdby');
} else {
Expand Down Expand Up @@ -137,7 +137,7 @@ public function init($pageurl) {
$this->setshowmineuserid();
}
$this->modify_base_url();
$this->filterform = new \question_bank_filter_form(
$this->filterform = new \mod_studentquiz_question_bank_filter_form(
$this->fields,
$pageurl->out(),
array('cmid' => $this->cm->id)
Expand Down Expand Up @@ -244,7 +244,7 @@ public function display($tabname, $page, $perpage, $cat,
global $PAGE, $OUTPUT;

$editcontexts = $this->contexts->having_one_edit_tab_cap($tabname);
array_unshift($this->searchconditions, new \mod_studentquiz\condition\student_quiz_condition(
array_unshift($this->searchconditions, new \mod_studentquiz\condition\studentquiz_condition(
$cat, $recurse, $editcontexts, $this->baseurl, $this->course));

// This function can be moderately slow with large question counts and may time out.
Expand Down Expand Up @@ -339,11 +339,11 @@ protected function build_query() {
$this->isfilteractive = true;
$sqldata = $field->get_sql_filter($data);

if ($field->_name == 'firstname' && !mod_check_created_permission()) {
if ($field->_name == 'firstname' && !mod_studentquiz_check_created_permission()) {
continue;
}

if ($field->_name == 'lastname' && !mod_check_created_permission()) {
if ($field->_name == 'lastname' && !mod_studentquiz_check_created_permission()) {
continue;
}

Expand Down Expand Up @@ -592,7 +592,7 @@ protected function filter_questions($questions) {
foreach ($questions as $question) {
$question->tagname = '';
if (
is_anonym($this->cm->id) &&
mod_studentquiz_is_anonym($this->cm->id) &&
$question->createdby != $USER->id
) {
$question->creatorfirstname = get_string('creator_anonym_firstname', 'studentquiz');
Expand Down
2 changes: 1 addition & 1 deletion export.php
Expand Up @@ -46,7 +46,7 @@
$PAGE->set_heading($COURSE->fullname);
echo $OUTPUT->header();

$exportform = new question_export_form($thispageurl,
$exportform = new mod_studentquiz_question_export_form($thispageurl,
array('contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']));


Expand Down
4 changes: 2 additions & 2 deletions export_form.php
Expand Up @@ -35,7 +35,7 @@
* @copyright 2007 Jamie Pratt me@jamiep.org
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class question_export_form extends moodleform {
class mod_studentquiz_question_export_form extends moodleform {

/**
* set form data
Expand All @@ -50,7 +50,7 @@ protected function definition() {
// Choice of format, with help.
$mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
$fileformatnames = get_import_export_formats('export');
$radioarray = array();

$i = 0;
foreach ($fileformatnames as $shortname => $fileformatname) {
$currentgrp1 = array();
Expand Down
4 changes: 2 additions & 2 deletions import.php
Expand Up @@ -37,7 +37,7 @@
require_login($course, false, $cm);

// Have to check it manual because moodle does not distinguish between add and import question.
if (!mod_check_created_permission()) {
if (!mod_studentquiz_check_created_permission()) {
print_error('nopermissions', '', '', 'access question edit tab import');
}

Expand Down Expand Up @@ -69,7 +69,7 @@

$PAGE->set_url($thispageurl);

$importform = new question_import_form($thispageurl, array('contexts' => $contexts->having_one_edit_tab_cap('import'),
$importform = new mod_studentquiz_question_import_form($thispageurl, array('contexts' => $contexts->having_one_edit_tab_cap('import'),
'defaultcategory' => $pagevars['cat']));

if ($importform->is_cancelled()) {
Expand Down
2 changes: 1 addition & 1 deletion import_form.php
Expand Up @@ -35,7 +35,7 @@
* @copyright 2007 Jamie Pratt me@jamiep.org
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class question_import_form extends moodleform {
class mod_studentquiz_question_import_form extends moodleform {

/**
* Set form.
Expand Down
15 changes: 4 additions & 11 deletions lib.php
Expand Up @@ -34,12 +34,7 @@
require_once($CFG->dirroot . '/lib/questionlib.php');
require_once(dirname(__FILE__) . '/locallib.php');

/**
* Example constant, you probably want to remove this :-)
*/
define('STUDENTQUIZ_ULTIMATE_ANSWER', 42);

/* Moodle core API */
/* Core API */

/**
* Returns the information on whether the module supports a feature
Expand Down Expand Up @@ -78,7 +73,7 @@ function studentquiz_supports($feature) {
* @return int The id of the newly inserted studentquiz record
*/
function studentquiz_add_instance(stdClass $studentquiz, mod_studentquiz_mod_form $mform = null) {
global $DB, $COURSE;
global $DB;

$studentquiz->timecreated = time();

Expand Down Expand Up @@ -385,7 +380,7 @@ function studentquiz_grade_item_delete($studentquiz) {
* @param int $userid update grade of specific user only, 0 means all participants
*/
function studentquiz_update_grades(stdClass $studentquiz, $userid = 0) {
global $CFG, $DB;
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

// Populate array of grade objects indexed by userid.
Expand Down Expand Up @@ -447,8 +442,6 @@ function studentquiz_get_file_info($browser, $areas, $course, $cm, $context, $fi
* @param array $options additional options affecting the file serving
*/
function studentquiz_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
global $DB, $CFG;

if ($context->contextlevel != CONTEXT_MODULE) {
send_file_not_found();
}
Expand Down Expand Up @@ -479,7 +472,7 @@ function studentquiz_extend_navigation(navigation_node $navref, stdClass $course
$navref->add(get_string('nav_report_rank', 'studentquiz')
, new moodle_url('/mod/studentquiz/reportrank.php?id=' . $cm->id));

if (mod_check_created_permission()) {
if (mod_studentquiz_check_created_permission()) {
$context = context_module::instance($cm->id);
$category = question_get_default_category($context->id);
$cat = 'cat=' . $category->id . ',' . $context->id;
Expand Down
34 changes: 17 additions & 17 deletions locallib.php
Expand Up @@ -32,30 +32,30 @@
/** @var string default quiz behaviour */
const STUDENTQUIZ_BEHAVIOUR = 'studentquiz';
/** @var int default course section id for the orphaned activities */
const COURSE_SECTION_ID = 999;
const STUDENTQUIZ_COURSE_SECTION_ID = 999;
/** @var string generated student quiz placeholder */
const GENERATE_QUIZ_PLACEHOLDER = 'quiz';
const STUDENTQUIZ_GENERATE_QUIZ_PLACEHOLDER = 'quiz';
/** @var string generated student quiz intro */
const GENERATE_QUIZ_INTRO = 'Studentquiz';
const STUDENTQUIZ_GENERATE_QUIZ_INTRO = 'Studentquiz';
/** @var string generated student quiz overduehandling */
const GENERATE_QUIZ_OVERDUEHANDLING = 'autosubmit';
const STUDENTQUIZ_GENERATE_QUIZ_OVERDUEHANDLING = 'autosubmit';
/** @var string default course section name for the orphaned activities */
const COURSE_SECTION_NAME = 'studentquiz quizzes';
const STUDENTQUIZ_COURSE_SECTION_NAME = 'studentquiz quizzes';
/** @var string default course section summary for the orphaned activities */
const COURSE_SECTION_SUMMARY = 'all student quizzes';
const STUDENTQUIZ_COURSE_SECTION_SUMMARY = 'all student quizzes';
/** @var string default course section summaryformat for the orphaned activities */
const COURSE_SECTION_SUMMARYFORMAT = 1;
const STUDENTQUIZ_COURSE_SECTION_SUMMARYFORMAT = 1;
/** @var string default course section visible for the orphaned activities */
const COURSE_SECTION_VISIBLE = false;
const STUDENTQUIZ_COURSE_SECTION_VISIBLE = false;
/** @var string default StudentQuiz quiz practice behaviour */
const DEFAULT_STUDENTQUIZ_QUIZ_BEHAVIOUR = 'immediatefeedback';
const STUDENTQUIZ_DEFAULT_QUIZ_BEHAVIOUR = 'immediatefeedback';

/**
* Checks whether the StudentQuiz behaviour exists
*
* @return bool
*/
function has_studentquiz_behaviour() {
function mod_studentquiz_has_behaviour() {
$archetypalbehaviours = question_engine::get_archetypal_behaviours();

return array_key_exists(STUDENTQUIZ_BEHAVIOUR, $archetypalbehaviours);
Expand All @@ -67,10 +67,10 @@ function has_studentquiz_behaviour() {
* @param stdClass $cm
* @return string quiz behaviour
*/
function get_current_behaviour($cm=null) {
function mod_studentquiz_get_current_behaviour($cm=null) {
global $DB;

$default = DEFAULT_STUDENTQUIZ_QUIZ_BEHAVIOUR;
$default = STUDENTQUIZ_DEFAULT_QUIZ_BEHAVIOUR;
$archetypalbehaviours = question_engine::get_archetypal_behaviours();

if (array_key_exists(STUDENTQUIZ_BEHAVIOUR, $archetypalbehaviours)) {
Expand All @@ -94,7 +94,7 @@ function get_current_behaviour($cm=null) {
* Returns quiz module id
* @return int
*/
function get_quiz_module_id() {
function mod_studentquiz_get_quiz_module_id() {
global $DB;
return $DB->get_field('modules', 'id', array('name' => 'quiz'));
}
Expand All @@ -103,7 +103,7 @@ function get_quiz_module_id() {
* Check if user has permission to see creator
* @return bool
*/
function mod_check_created_permission() {
function mod_studentquiz_check_created_permission() {
global $USER;

$admins = get_admins();
Expand All @@ -123,17 +123,17 @@ function mod_check_created_permission() {
* @param int $cmid course module id
* @return boolean
*/
function is_anonym($cmid) {
function mod_studentquiz_is_anonym($cmid) {
global $DB;

if (mod_check_created_permission()) {
if (mod_studentquiz_check_created_permission()) {
return 0;
}

$field = $DB->get_field('studentquiz', 'anonymrank', array('coursemodule' => $cmid));
if ($field !== false) {
return intval($field);
}
// If the dont found an entry better set it anonym.
// If no entry was found, better set it anonym.
return 1;
}
6 changes: 3 additions & 3 deletions mod_form.php
Expand Up @@ -74,15 +74,15 @@ public function definition() {
$mform->addHelpButton('anonymrank', 'anonymrankhelp', 'studentquiz');
$mform->setDefault('anonymrank', 1);

if (has_studentquiz_behaviour()) {
if (mod_studentquiz_has_behaviour()) {
$mform->addElement('advcheckbox', 'quizpracticebehaviour', get_string('quizpracticebehaviour', 'studentquiz')
, null, null, array(DEFAULT_STUDENTQUIZ_QUIZ_BEHAVIOUR, STUDENTQUIZ_BEHAVIOUR));
, null, null, array(STUDENTQUIZ_DEFAULT_QUIZ_BEHAVIOUR, STUDENTQUIZ_BEHAVIOUR));
$mform->setType('quizpracticebehaviour', PARAM_RAW);
$mform->addHelpButton('quizpracticebehaviour', 'quizpracticebehaviourhelp', 'studentquiz');

$mform->setDefault('quizpracticebehaviour', STUDENTQUIZ_BEHAVIOUR);
} else {
$mform->addElement('hidden', 'quizpracticebehaviour', DEFAULT_STUDENTQUIZ_QUIZ_BEHAVIOUR);
$mform->addElement('hidden', 'quizpracticebehaviour', STUDENTQUIZ_DEFAULT_QUIZ_BEHAVIOUR);
$mform->setType('quizpracticebehaviour', PARAM_RAW);
}

Expand Down
6 changes: 3 additions & 3 deletions renderer.php
Expand Up @@ -35,7 +35,7 @@ class mod_studentquiz_renderer extends plugin_renderer_base {

/**
* builds the rank report table
* @param studentquiz_report $report studentquiz_report class with necessary information
* @param mod_studentquiz_report $report studentquiz_report class with necessary information
* @return string rank report table
* @throws coding_exception
*/
Expand Down Expand Up @@ -86,7 +86,7 @@ public function view_rankreport_table($report) {

/**
* Builds the quiz report table for the admin
* @param studentquiz_report $report studentquiz_report class with necessary information
* @param mod_studentquiz_report $report studentquiz_report class with necessary information
* @param stdClass $usersdata
* @return string rank report table
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ public function view_quizreport_table($report, $usersdata) {

/**
* Builds the quiz admin report view with the created quizzes
* @param studentquiz_report $report studentquiz_report class with necessary information
* @param mod_studentquiz_report $report studentquiz_report class with necessary information
* @param stdClass $quizzes
* @return string rank report table
*/
Expand Down

0 comments on commit 602a5ba

Please sign in to comment.