-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from KQMATH/development
v0.2 release
- Loading branch information
Showing
48 changed files
with
1,470 additions
and
298 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package mod_capquiz | ||
* @author Sebastian S. Gundersen <sebastian@sgundersen.com> | ||
* @copyright 2019 NTNU | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
define(['jquery', 'core/str'], function($, mString) { | ||
|
||
/** | ||
* | ||
* @param $form | ||
*/ | ||
function moveCommentFieldToForm($form) { | ||
var $comment = $('.capquiz-student-comment'); | ||
if ($comment.find('textarea').val().length) { | ||
$comment.prop('open', true); | ||
} | ||
$form.prepend($comment); | ||
} | ||
|
||
function showTooltip($element, text) { | ||
var $tooltip = $('.capquiz-star-tooltip'); | ||
$tooltip.html(text); | ||
$tooltip.css('display', 'block'); | ||
var x = $element.offset().left - $tooltip.width() / 2; | ||
var y = $element.offset().top + 32; | ||
$tooltip.css('left', x + 'px'); | ||
$tooltip.css('top', y + 'px'); | ||
} | ||
|
||
function hideTooltip() { | ||
$('.capquiz-star-tooltip').css('display', 'none'); | ||
} | ||
|
||
function enableTooltips() { | ||
$(document).on('mouseover', '.capquiz-quiz-stars span', function () { | ||
var $self = $(this); | ||
if ($self.hasClass('capquiz-star')) { | ||
$.when(mString.get_string('tooltip_achieved_star', 'capquiz')).done(function (text) { | ||
showTooltip($self, text); | ||
}); | ||
} else if ($self.hasClass('capquiz-lost-star')) { | ||
$.when(mString.get_string('tooltip_lost_star', 'capquiz')).done(function (text) { | ||
showTooltip($self, text); | ||
}); | ||
} else if ($self.hasClass('capquiz-no-star')) { | ||
$.when(mString.get_string('tooltip_no_star', 'capquiz')).done(function (text) { | ||
showTooltip($self, text); | ||
}); | ||
} else if ($self.hasClass('capquiz-help-stars')) { | ||
$.when(mString.get_string('tooltip_help_star', 'capquiz')).done(function (text) { | ||
showTooltip($self, text); | ||
}); | ||
} | ||
}); | ||
$(document).on('mouseleave', '.capquiz-quiz-stars span', function () { | ||
hideTooltip(); | ||
}); | ||
} | ||
|
||
return { | ||
initialize: function() { | ||
var $nextButton = $('#capquiz_review_next'); | ||
if ($nextButton.length) { | ||
moveCommentFieldToForm($nextButton.parent()); | ||
} | ||
enableTooltips(); | ||
} | ||
}; | ||
|
||
}); |
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
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
Oops, something went wrong.