forked from jhoopes/moodle-mod_activequiz
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
280 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: <[email protected]> | ||
|
||
**Developer:** Sebastian S. Gundersen: <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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 = { | ||
|
@@ -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')); | ||
} | ||
|
||
|
@@ -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]; | ||
|
@@ -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); | ||
} | ||
|
@@ -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) { | ||
|
@@ -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'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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. | ||
|
@@ -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; | ||
|
@@ -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) { | ||
|
@@ -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); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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; | ||
|
@@ -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'); | ||
|
@@ -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. | ||
|
@@ -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'); | ||
}; | ||
|
||
|
@@ -299,7 +299,7 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) { | |
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Sort the responses in the graph by how many had the same response. | ||
|
@@ -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? | ||
|
@@ -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(); | ||
} | ||
|
@@ -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'); | ||
|
@@ -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'); | ||
|
@@ -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, () => {}); | ||
} | ||
|
||
|
@@ -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]); | ||
} | ||
|
||
|
@@ -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(); | ||
|
@@ -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) { | ||
|
@@ -978,6 +980,6 @@ define(['jquery', 'mod_jazzquiz/core'], function ($, Jazz) { | |
quiz.poll(500); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
}); |
Oops, something went wrong.