Skip to content

Commit

Permalink
Merge pull request #127 from KQMATH/development
Browse files Browse the repository at this point in the history
v0.3.0
  • Loading branch information
sebastsg authored Jun 27, 2019
2 parents c5f0df4 + e281162 commit 07ae7f0
Show file tree
Hide file tree
Showing 65 changed files with 902 additions and 881 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Changed
-

## [0.3.0] - 2019-06-27
### Added
- Added support for Moodle grading system
- Added button to add all selected (checked) questions to question list
- Number of stars is now configurable
- Class list is improved (sorting by columns)

### Changed
- Merged some tabs to simplify user interface
- Rounded user ratings in class list

### Fixed
- Add some missing language strings

## [0.2.0] - 2019-06-24
### Added
* Questions can now be sorted by name and rating
Expand Down Expand Up @@ -45,8 +59,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## 0.1.0 - 2018-09-28

[Unreleased]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.3.0...HEAD

[0.3.0]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.1.5...v0.2.0
[0.1.5]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/KQMATH/moodle-mod_capquiz/compare/v0.1.3...v0.1.4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CAPQuiz includes the work of many [contributors](https://github.com/KQMATH/moodl

**Developers:**
* Aleksander Skrede <aleksander.skrede@gmail.com>
* Sebastian S. Gundersen <sebastsg@stud.ntnu.no>
* Sebastian S. Gundersen <sebastian@sgundersen.com>
* [André Storhaug](https://github.com/andstor) <andr3.storhaug@gmail.com>

**Original idea:**
Expand Down
5 changes: 3 additions & 2 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
$context = \context_module::instance($cmid);
require_capability('mod/capquiz:instructor', $context);

$action = required_param(capquiz_actions::$parameter, PARAM_TEXT);
$action = required_param('action', PARAM_TEXT);

$capquiz = capquiz::create();
$cmid = capquiz_urls::require_course_module_id_param();
$capquiz = new capquiz($cmid);
if ($capquiz) {
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync);
capquiz_action_performer::perform($action, $capquiz);
Expand Down
2 changes: 1 addition & 1 deletion amd/build/edit_questions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion amd/src/attempt.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
define(['jquery', 'core/str'], function($, mString) {

/**
*
* @param $form
*/
function moveCommentFieldToForm($form) {
Expand All @@ -34,6 +33,11 @@ define(['jquery', 'core/str'], function($, mString) {
$form.prepend($comment);
}

/**
* Show star tooltip.
* @param $element
* @param text
*/
function showTooltip($element, text) {
var $tooltip = $('.capquiz-star-tooltip');
$tooltip.html(text);
Expand All @@ -44,10 +48,16 @@ define(['jquery', 'core/str'], function($, mString) {
$tooltip.css('top', y + 'px');
}

/**
* Hide star tooltip.
*/
function hideTooltip() {
$('.capquiz-star-tooltip').css('display', 'none');
}

/**
* Register event listeners for showing tooltips on the stars.
*/
function enableTooltips() {
$(document).on('mouseover', '.capquiz-quiz-stars span', function () {
var $self = $(this);
Expand Down
41 changes: 34 additions & 7 deletions amd/src/edit_questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

/**
* @package mod_capquiz
* @author Sebastian S. Gundersen <sebastsg@stud.ntnu.no>
* @copyright 2018 NTNU
* @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'], function($) {

var parameters = {
capquizId: 0,
courseModuleId: 0,
};

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ define(['jquery'], function($) {
function sendDefaultQuestionRating(data, rating, onSuccess, onError) {
sendAction({
'action': 'set-default-question-rating',
'id': parameters.capquizId,
'id': parameters.courseModuleId,
'rating': rating,
}, onSuccess, onError);
}
Expand All @@ -67,7 +67,7 @@ define(['jquery'], function($) {
function sendQuestionRating(data, rating, onSuccess, onError) {
sendAction({
'action': 'set-question-rating',
'id': parameters.capquizId,
'id': parameters.courseModuleId,
'question-id': data.questionId,
'rating': rating,
}, onSuccess, onError);
Expand Down Expand Up @@ -189,6 +189,13 @@ define(['jquery'], function($) {
$(document).on('click', '.capquiz-sortable', function() {
sortTable($(this));
});
$('.capquiz-sortable-default-asc').each(function () {
sortTable($(this));
sortTable($(this));
});
$('.capquiz-sortable-default-desc').each(function () {
sortTable($(this));
});
}

/**
Expand All @@ -200,13 +207,33 @@ define(['jquery'], function($) {
});
}

/**
* Register click event listener for "Add to quiz" button.
*/
function listenAddToQuiz() {
$('.capquiz-add-selected-questions').on('click', function () {
var questionIds = '';
$('#categoryquestions td input[type=checkbox]:checked').each(function () {
questionIds += $(this).attr('name').slice(1) + ',';
});
$.post('action.php', {
'action': 'add-question',
'id': parameters.courseModuleId,
'question-id': questionIds,
}, function () {
location.reload();
});
});
}

return {
initialize: function(capquizId) {
parameters.capquizId = capquizId;
initialize: function(courseModuleId) {
parameters.courseModuleId = courseModuleId;
registerListener('.capquiz-question-rating input', submitQuestionRating);
registerListener('.capquiz-default-question-rating input', submitDefaultQuestionRating);
fixTabIndicesForQuestionRatingInputs();
registerSortListener();
listenAddToQuiz();
}
};

Expand Down
11 changes: 6 additions & 5 deletions async.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@
$context = \context_module::instance($cmid);
require_capability('mod/capquiz:student', $context);

$action = required_param(capquiz_actions::$parameter, PARAM_TEXT);
$attemptid = optional_param(capquiz_urls::$paramattempt, null, PARAM_INT);
$action = required_param('action', PARAM_TEXT);
$attemptid = optional_param('attempt', null, PARAM_INT);
$comment = optional_param('studentcomment', '', PARAM_TEXT);
$capquiz = capquiz::create();
$cmid = capquiz_urls::require_course_module_id_param();
$capquiz = new capquiz($cmid);

capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync);

if ($attemptid !== null) {
$user = $capquiz->user();
$attempt = capquiz_question_attempt::load_attempt($capquiz, $user, $attemptid);
$attempt->update_student_comment($comment);
if ($action === capquiz_actions::$attemptanswered) {
if ($action === 'answered') {
$capquiz->question_engine()->attempt_answered($user, $attempt);
} else if ($action === capquiz_actions::$attemptreviewed) {
} else if ($action === 'reviewed') {
$capquiz->question_engine()->attempt_reviewed($attempt);
}
capquiz_urls::redirect_to_dashboard();
Expand Down
3 changes: 1 addition & 2 deletions backup/moodle2/backup_capquiz_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ protected function define_structure() {
]);
$questionlist = new backup_nested_element('questionlist', null, [
'id', 'capquiz_id', 'question_usage_id', 'title', 'author', 'description',
'level_1_rating', 'level_2_rating', 'level_3_rating', 'level_4_rating', 'level_5_rating',
'is_template', 'time_created', 'time_modified', 'default_question_rating'
'star_ratings', 'is_template', 'time_created', 'time_modified', 'default_question_rating'
]);
$this->add_question_usages($questionlist, 'question_usage_id');
$questions = new backup_nested_element('questions');
Expand Down
6 changes: 6 additions & 0 deletions classes/bank/question_bank_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ public function render(string $tabname, int $page, int $perpage, string $categor
$showquestiontext,
$this->contexts->having_cap('moodle/question:add')
);
$this->display_add_selected_questions_button();
$PAGE->requires->js_call_amd('core_question/edit_tags', 'init', ['#questionscontainer']);
return ob_get_clean();
}

private function display_add_selected_questions_button() {
$straddtoquiz = get_string('add_to_quiz', 'capquiz');
echo '<button class="btn btn-secondary capquiz-add-selected-questions">' . $straddtoquiz . '</button>';
}

}
Loading

0 comments on commit 07ae7f0

Please sign in to comment.