Skip to content

Commit

Permalink
Merge pull request #57 from KQMATH/develop
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
andstor committed Jul 30, 2019
2 parents 53fc94e + 45cf09f commit aa4899a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
22 changes: 19 additions & 3 deletions backup/moodle2/backup_jazzquiz_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ protected function define_structure() {
'timecreated',
'timemodified',
'defaultquestiontime',
'waitforquestiontime'
'waitforquestiontime',
'cfganonymity',
'cfgallowguests'
]);

$questions = new backup_nested_element('questions');
Expand All @@ -53,7 +55,9 @@ protected function define_structure() {
'slot',
'currentquestiontime',
'nextstarttime',
'created'
'created',
'anonymity',
'allowguests'
]);

$sessionquestions = new backup_nested_element('sessionquestions');
Expand All @@ -74,7 +78,8 @@ protected function define_structure() {
'responded',
'timestart',
'timefinish',
'timemodified'
'timemodified',
'guestsession'
]);
$this->add_question_usages($attempt, 'questionengid');

Expand All @@ -98,6 +103,13 @@ protected function define_structure() {
'slot'
]);

$attendances = new backup_nested_element('attendances');
$attendance = new backup_nested_element('attendance', ['id'], [
'sessionid',
'userid',
'numresponses'
]);

// Build the tree.
$jazzquiz->add_child($questions);
$jazzquiz->add_child($sessions);
Expand All @@ -109,11 +121,13 @@ protected function define_structure() {
$session->add_child($attempts);
$session->add_child($merges);
$session->add_child($votes);
$session->add_child($attendances);

$sessionquestions->add_child($sessionquestion);
$attempts->add_child($attempt);
$merges->add_child($merge);
$votes->add_child($vote);
$attendances->add_child($attendance);

// Define sources.
$jazzquiz->set_source_table('jazzquiz', ['id' => backup::VAR_ACTIVITYID]);
Expand All @@ -122,6 +136,7 @@ protected function define_structure() {
$session->set_source_table('jazzquiz_sessions', ['jazzquizid' => backup::VAR_PARENTID]);
$sessionquestion->set_source_table('jazzquiz_session_questions', ['sessionid' => backup::VAR_PARENTID]);
$attempt->set_source_table('jazzquiz_attempts', ['sessionid' => backup::VAR_PARENTID]);
$attendance->set_source_table('jazzquiz_attendance', ['sessionid' => backup::VAR_PARENTID]);
$merge->set_source_table('jazzquiz_merges', ['sessionid' => backup::VAR_PARENTID]);
$vote->set_source_table('jazzquiz_votes', [
'jazzquizid' => backup::VAR_ACTIVITYID,
Expand All @@ -131,6 +146,7 @@ protected function define_structure() {

// Define id annotations.
$attempt->annotate_ids('user', 'userid');
$attendance->annotate_ids('user', 'userid');
$question->annotate_ids('question', 'questionid');
$sessionquestion->annotate_ids('question', 'questionid');

Expand Down
11 changes: 11 additions & 0 deletions backup/moodle2/restore_jazzquiz_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected function define_structure() {
$paths[] = new restore_path_element('jazzquiz_session_question', '/activity/jazzquiz/sessions/session/sessionquestions/sessionquestion');
$paths[] = new restore_path_element('jazzquiz_merge', '/activity/jazzquiz/sessions/session/merges/merge');
$paths[] = new restore_path_element('jazzquiz_vote', '/activity/jazzquiz/sessions/session/votes/vote');
$paths[] = new restore_path_element('jazzquiz_attendance', '/activity/jazzquiz/sessions/session/attendances/attendance');
$attempt = new restore_path_element('jazzquiz_attempt', '/activity/jazzquiz/sessions/session/attempts/attempt');
$paths[] = $attempt;
$this->add_question_usages($attempt, $paths);
Expand Down Expand Up @@ -124,6 +125,16 @@ protected function process_jazzquiz_vote($data) {
$this->set_mapping('jazzquiz_vote', $oldid, $newitemid);
}

protected function process_jazzquiz_attendance($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->userid = $this->get_mappingid('user', $data->userid);
$data->sessionid = $this->get_new_parentid('jazzquiz_session');
$newitemid = $DB->insert_record('jazzquiz_attendance', $data);
$this->set_mapping('jazzquiz_attendance', $oldid, $newitemid);
}

protected function after_execute() {
$this->add_related_files('mod_jazzquiz', 'intro', null);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/forms/view/start_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function definition() {
$mform->createElement('radio', 'anonymity', '', get_string('fully_anonymous', 'jazzquiz'), 2, []),
$mform->createElement('radio', 'anonymity', '', get_string('nonanonymous_session', 'jazzquiz'), 3, [])
];
$mform->addGroup($anonymity,'anonymity', '', ['<br>', ''], false);
$mform->addGroup($anonymity, 'anonymity', '', ['<br>', ''], false);
$mform->setDefault('anonymity', $jazzquiz->data->cfganonymity);
$mform->addElement('checkbox', 'allowguests', '', get_string('allow_guests', 'jazzquiz'));
$mform->setDefault('allowguests', $jazzquiz->data->cfgallowguests);
Expand Down
17 changes: 17 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ function jazzquiz_cron() {
return true;
}

/**
* This function extends the settings navigation block for the site.
*
* @param settings_navigation $settings
* @param navigation_node $jazzquiznode
* @return void
*/
function jazzquiz_extend_settings_navigation($settings, $jazzquiznode) {
global $PAGE, $CFG;

// Require {@link questionlib.php}
// Included here as we only ever want to include this file if we really need to.
require_once($CFG->libdir . '/questionlib.php');

question_extend_settings_navigation($jazzquiznode, $PAGE->cm->context)->trim_if_empty();
}

/**
* @param \stdClass|int $course
* @param \stdClass $cm
Expand Down
5 changes: 3 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
/**
* @package mod_jazzquiz
* @author Sebastian S. Gundersen <[email protected]>
* @author André Storhaug <[email protected]>
* @copyright 2014 University of Wisconsin - Madison
* @copyright 2019 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2019062100; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2019073000; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2018051700; // Moodle 3.5 (or above)
$plugin->cron = 0; // Period in seconds for cron to run.
$plugin->component = 'mod_jazzquiz';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '0.9.3 (Build: 2019062100)';
$plugin->release = '1.0.0 (Build: 2019073000)';

0 comments on commit aa4899a

Please sign in to comment.