Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Georg Schaathun committed Aug 21, 2023
2 parents be494fc + 7387972 commit 84863e8
Show file tree
Hide file tree
Showing 26 changed files with 280 additions and 88 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

services:
postgres:
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker --max-warnings 0
run: moodle-plugin-ci codechecker

- name: Moodle PHPDoc Checker
if: ${{ always() }}
Expand All @@ -93,7 +93,7 @@ jobs:

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0
run: moodle-plugin-ci grunt

- name: PHPUnit tests
if: ${{ always() }}
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]
### Changed
-

## [1.2.1] - 2023-08-21

- Changed submission button for student answer changed from Save to Submit.
- Fixed various codestyle issues.
- Added column in qbank view for displaying question text/media
- Swapped the order of firstname and lastname in csv export of attendance list
- Improvement of guest user feedback upon trying to attend a quiz which doesn't allow guests to attend
- Added new template for "guests_not_allowed" feedback

## [1.2.0] - 2023-03-31

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ The teacher can, at a later date, go back through the results and, for each ques
The repolls are treated as separate questions, and you will get a correct order in the review page.

## Documentation
Documentation is available [here](https://github.com/KQMATH/moodle-mod_jazzquiz/wiki), including [installation instructions](https://github.com/KQMATH/moodle-mod_jazzquiz/wiki/Installation-instructions).


Documentation is available as
[github pages](https://kqmath.github.io/) at
[https://kqmath.github.io/docs/jazzquiz/](https://kqmath.github.io/docs/jazzquiz/)

## Feedback:

**Project lead:** Hans Georg Schaathun: <hasc@ntnu.no>

**Developer:** Sebastian S. Gundersen: <sebastsg@stud.ntnu.no>
Expand Down
18 changes: 8 additions & 10 deletions amd/src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_jazzquiz
* @module mod_jazzquiz
* @author Sebastian S. Gundersen <sebastsg@stud.ntnu.no>
* @copyright 2014 University of Wisconsin - Madison
* @copyright 2018 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function ($, mConfig, mString, Y, mEvent) {
define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function($, mConfig, mString, Y, mEvent) {

// Contains the needed values for using the ajax script.
let session = {
Expand Down Expand Up @@ -56,10 +56,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function
url: url,
data: data,
dataType: 'json',
success: success,
error: function (xhr, status, error) {
//console.error('XHR Error: ' + error + '. Status: ' + status);
}
success: success
}).fail(() => setText(Quiz.info, 'error_with_request'));
}

Expand Down Expand Up @@ -126,6 +123,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function
return;
}
Quiz.show(Question.box.html(data.html));
// eslint-disable-next-line no-eval
eval(data.js);
data.css.forEach(cssUrl => {
let head = document.getElementsByTagName('head')[0];
Expand Down Expand Up @@ -265,7 +263,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function
changeQuizState(state, data) {
this.isNewState = (this.state !== state);
this.state = state;
this.role.onStateChange(state);
this.role.onStateChange();
const event = this.events[state];
this.role[event](data);
}
Expand Down Expand Up @@ -342,7 +340,7 @@ define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function
static renderMaximaEquation(input, targetId) {
const target = document.getElementById(targetId);
if (target === null) {
//console.error('Target element #' + targetId + ' not found.');
// Log error to console: 'Target element #' + targetId + ' not found.'.
return;
}
if (cache[input] !== undefined) {
Expand All @@ -359,10 +357,10 @@ define(['jquery', 'core/config', 'core/str', 'core/yui', 'core/event'], function

/**
* Retrieve a language string that was sent along with the page.
* @param $element
* @param {*} $element
* @param {string} key Which string in the language file we want.
* @param {string} [from=jazzquiz] Which language file we want the string from. Default is jazzquiz.
* @param [args] This is {$a} in the string for the key.
* @param {array} args This is {$a} in the string for the key.
*/
function setText($element, key, from, args) {
from = (from !== undefined) ? from : 'jazzquiz';
Expand Down
29 changes: 20 additions & 9 deletions amd/src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


import Sortable from '../../js/sortable.min.js';

/**
* @package mod_jazzquiz
* @module mod_jazzquiz
* @author Sebastian S. Gundersen <sebastsg@stud.ntnu.no>
* @copyright 2015 University of Wisconsin - Madison
* @copyright 2018 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['jquery'], function ($) {
define(['jquery'], function($) {

/**
* Submit the question order to the server. An empty array will delete all questions.
Expand All @@ -41,7 +44,7 @@ define(['jquery'], function ($) {
*/
function getQuestionOrder() {
let order = [];
$('.questionlist li').each(function () {
$('.questionlist li').each(function() {
order.push($(this).data('question-id'));
});
return order;
Expand Down Expand Up @@ -69,8 +72,12 @@ define(['jquery'], function ($) {
return order;
}

/**
* Add click-listener to a quiz by module id.
* @param {number} courseModuleId
*/
function listenAddToQuiz(courseModuleId) {
$('.jazzquiz-add-selected-questions').on('click', function () {
$('.jazzquiz-add-selected-questions').on('click', function() {
const $checkboxes = $('#categoryquestions td input[type=checkbox]:checked');
let questionIds = '';
for (const checkbox of $checkboxes) {
Expand All @@ -86,26 +93,30 @@ define(['jquery'], function ($) {

return {
initialize: courseModuleId => {
$('.edit-question-action').on('click', function () {
$('.edit-question-action').on('click', function() {
const action = $(this).data('action');
const questionId = $(this).data('question-id');
let order = [];
switch (action) {
case 'up':
case 'up': {
order = offsetQuestion(questionId, 1);
break;
case 'down':
}
case 'down': {
order = offsetQuestion(questionId, -1);
break;
case 'delete':
}
case 'delete': {
order = getQuestionOrder();
const index = order.indexOf(questionId);
if (index !== -1) {
order.splice(index, 1);
}
break;
default:
}
default: {
return;
}
}
submitQuestionOrder(order, courseModuleId);
});
Expand Down
30 changes: 16 additions & 14 deletions amd/src/instructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package mod_jazzquiz
* @module mod_jazzquiz
* @author Sebastian S. Gundersen <sebastsg@stud.ntnu.no>
* @copyright 2014 University of Wisconsin - Madison
* @copyright 2018 NTNU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
define(['jquery', 'mod_jazzquiz/core'], function($, Jazz) {

const Quiz = Jazz.Quiz;
const Question = Jazz.Question;
Expand Down Expand Up @@ -140,7 +140,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
}
$row.addClass('merge-from');
let $table = $row.parent().parent();
$table.find('tr').each(function () {
$table.find('tr').each(function() {
const $cells = $(this).find('td');
if ($cells[1].id !== $barCell.attr('id')) {
$(this).addClass('merge-into');
Expand Down Expand Up @@ -233,7 +233,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {

// Add rows.
for (let i = 0; i < responses.length; i++) {
//const percent = (parseInt(responses[i].count) / total) * 100;
// Const percent = (parseInt(responses[i].count) / total) * 100;
const percent = (parseInt(responses[i].count) / highestResponseCount) * 100;

// Check if row with same response already exists.
Expand Down Expand Up @@ -262,7 +262,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {

const countHtml = '<span id="' + name + '_count_' + rowIndex + '">' + responses[i].count + '</span>';
let responseCell = row.insertCell(0);
responseCell.onclick = function () {
responseCell.onclick = function() {
$(this).parent().toggleClass('selected-vote-option');
};

Expand Down Expand Up @@ -299,7 +299,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
}
}
}
};
}

/**
* Sort the responses in the graph by how many had the same response.
Expand Down Expand Up @@ -440,7 +440,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
}

/**
* refresh() equivalent for votes.
* Method refresh() equivalent for votes.
*/
refreshVotes() {
// Should we show the results?
Expand Down Expand Up @@ -687,15 +687,15 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
this.quiz.question.isRunning = false;
}

onSessionClosed(data) {
onSessionClosed() {
Quiz.hide(Instructor.side);
Quiz.hide(Instructor.correctAnswer);
Instructor.enableControls([]);
this.responses.clear();
this.quiz.question.isRunning = false;
}

onVoting(data) {
onVoting() {
if (!this.responses.showResponses) {
this.responses.hide();
}
Expand All @@ -704,7 +704,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
this.responses.refreshVotes();
}

onStateChange(state) {
onStateChange() {
$('#region-main').find('ul.nav.nav-tabs').css('display', 'none');
$('#region-main-settings-menu').css('display', 'none');
$('.region_main_settings_menu_proxy').css('display', 'none');
Expand Down Expand Up @@ -776,7 +776,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
'jazzquiz-question-id': questions[i].jazzquizquestionid
});
$questionButton.data('test', 1);
$questionButton.on('click', function () {
$questionButton.on('click', function() {
const questionId = $(this).data('question-id');
const time = $(this).data('time');
const jazzQuestionId = $(this).data('jazzquiz-question-id');
Expand Down Expand Up @@ -810,6 +810,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
runVoting() {
const options = Instructor.getSelectedAnswersForVote();
const data = {questions: encodeURIComponent(JSON.stringify(options))};
// eslint-disable-next-line no-return-assign
Ajax.post('run_voting', data, () => {});
}

Expand Down Expand Up @@ -871,6 +872,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
Quiz.hide(Question.box);
Quiz.hide(Instructor.controls);
setText(Quiz.info, 'closing_session');
// eslint-disable-next-line no-return-assign
Ajax.post('close_session', {}, () => window.location = location.href.split('&')[0]);
}

Expand Down Expand Up @@ -947,7 +949,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
}

static addReportEventHandlers() {
$(document).on('click', '#report_overview_controls button', function () {
$(document).on('click', '#report_overview_controls button', function() {
const action = $(this).data('action');
if (action === 'attendance') {
$('#report_overview_responded').fadeIn();
Expand All @@ -962,7 +964,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
}

return {
initialize: function (totalQuestions, reportView, slots) {
initialize: function(totalQuestions, reportView, slots) {
let quiz = new Quiz(Instructor);
quiz.role.totalQuestions = totalQuestions;
if (reportView) {
Expand All @@ -978,6 +980,6 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) {
quiz.poll(500);
}
}
}
};

});
Loading

0 comments on commit 84863e8

Please sign in to comment.