Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 20 additions & 37 deletions evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ M.mod_ojt_evaluate = M.mod_ojt_evaluate || {
var config = this.config;

// Init ojt topic item selection toggle
$('.mod-ojt-topic-item-selection-label').on('click', function() {
$('.mod-ojt-topic-item-selection-container').on('click', function(e) {
var topicitemselection = $(this);
var itemid = topicitemselection.parent().attr('ojt-item-id');
var itemid = topicitemselection.data('itemid');
var choice = topicitemselection.data('choice');
// console.log('Clicked', e.target.tagName);
// Avoid firing the event twice, one for input, the other for label
if (e.target.tagName === 'LABEL') {
return;
}
$.ajax({
url: M.cfg.wwwroot + '/mod/ojt/evaluatesave.php',
type: 'POST',
Expand All @@ -69,14 +75,24 @@ M.mod_ojt_evaluate = M.mod_ojt_evaluate || {
'action': 'complete',
'bid': config.ojtid,
'userid': config.userid,
'id': itemid
'id': itemid,
'comment': choice
},
success: function(data) {
// Update the topic's completion too.
ojtobj.setTopicStatusIcon(data.item.status, $('#ojt-topic-' + data.item.topicid + ' .ojt-topic-status'));
ojtobj.setTopicStatusIcon(data.topic.status, $('#ojt-topic-' + data.item.topicid + ' .ojt-topic-status'));

// Update modified string.
$('.mod-ojt-modifiedstr[ojt-item-id=' + itemid + ']').html(data.modifiedstr);

// Update the comment print box
$('.ojt-completion-comment-print[ojt-item-id='+itemid+']').html(data.item.comment);
$('.mod-ojt-modifiedstr[ojt-item-id='+itemid+']').html(data.modifiedstr);
// Trigger click if checkbox icon is unchecked.
$selector = $(".ojt-eval-actions[ojt-item-id='"+itemid+"'] span[data-flex-icon]");
if ($selector.length && $selector[0].classList.contains("fa-square-o")) {
$selector.trigger("click");
}
},
error: function(data) {
console.log(data);
Expand Down Expand Up @@ -155,39 +171,6 @@ M.mod_ojt_evaluate = M.mod_ojt_evaluate || {
});
});

$('span.mod-ojt-item-type-select input').change(function() {
var commentinput = this;
var itemid = $(this).parent().attr('ojt-item-id');

$.ajax({
url: M.cfg.wwwroot+'/mod/ojt/evaluatesave.php',
type: 'POST',
data: {
'sesskey' : M.cfg.sesskey,
'action': 'savecomment',
'bid': config.ojtid,
'userid': config.userid,
'id': itemid,
'comment': $(commentinput).val()
},
success: function(data) {
// Unlike text comments, no update for the value here.
// Update the comment print box
$('.ojt-completion-comment-print[ojt-item-id='+itemid+']').html(data.item.comment);
$('.mod-ojt-modifiedstr[ojt-item-id='+itemid+']').html(data.modifiedstr);
// Trigger click if checkbox icon is unchecked.
$selector = $(".ojt-eval-actions[ojt-item-id='"+itemid+"'] span[data-flex-icon]");
if ($selector.length && $selector[0].classList.contains("fa-square-o")) {
$selector.trigger("click");
}
},
error: function(data) {
console.log(data);
alert('Error saving comment...');
}
});
});

// Init completion witness toggle.
$('.ojt-witness-toggle').on('click', function() {
var completionimg = $(this);
Expand Down
2 changes: 1 addition & 1 deletion evaluatesave.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
break;
case 'complete':
$completion->status = OJT_COMPLETE;
break;
case 'savecomment':
$completion->comment = required_param('comment', PARAM_TEXT);
// append a date to the comment string
Expand All @@ -91,6 +90,7 @@
$completion->status = OJT_COMPLETE;
break;
case 'complete':
$completion->status = OJT_COMPLETE;
case 'savecomment':
$completion->comment = required_param('comment', PARAM_TEXT);
// append a date to the comment string
Expand Down
2 changes: 1 addition & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function ojt_get_user_ojt($ojtid, $userid) {
$items = $DB->get_records_sql($sql, $params);

foreach ($items as $i => $item) {
$ojt->topics[$item->topicid]->items[$i] = $item;
$ojt->topics[$item->topicid]->items[$i] = clone($item);
}

return $ojt;
Expand Down
4 changes: 2 additions & 2 deletions rb_sources/rb_source_ojt_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ function rb_filter_ojt_type_list() {

/**
* Inject column_test data into database.
* @param totara_reportbuilder_column_testcase $testcase
* @param totara_reportbuilder_column_test $testcase
*/
public function phpunit_column_test_add_data(totara_reportbuilder_column_testcase $testcase) {
public function phpunit_column_test_add_data(totara_reportbuilder_column_test $testcase) {
global $DB;

if (!PHPUNIT_TEST) {
Expand Down
4 changes: 2 additions & 2 deletions rb_sources/rb_source_ojt_topic_item_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ function rb_filter_ojt_completion_status_list() {

/**
* Inject column_test data into database.
* @param totara_reportbuilder_column_testcase $testcase
* @param totara_reportbuilder_column_test $testcase
*/
public function phpunit_column_test_add_data(totara_reportbuilder_column_testcase $testcase) {
public function phpunit_column_test_add_data(totara_reportbuilder_column_test $testcase) {
global $DB;

if (!PHPUNIT_TEST) {
Expand Down
27 changes: 20 additions & 7 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,26 @@ function user_ojt(stdClass $userojt, bool $evaluate = false, bool $signoff = fal
'name' => "comment-{$item->id}",
'value' => $choice,
'type' => 'radio',
'style' => 'cursor:pointer',
);
if ($choice == $comment) {
// Comparing "Needs Improvement - 16/10/25, 11:51." to "Needs Improvement"
if (strpos($comment, $choice) === 0) {
$inputattrs['checked'] = true;
}
$cellcontent .= html_writer::tag('input', '', $inputattrs);
$cellcontent .= html_writer::tag('label', $choice, array(
'for' => "comment-{$item->id}-$i",
'class' => 'mod-ojt-topic-item-selection-label'
));
$cellcontent .= html_writer::start_tag('span',
[
'class' => 'mod-ojt-topic-item-selection-container',
'data-itemid' => $item->id,
'data-choice' => htmlspecialchars($choice),
]
);
$cellcontent .= html_writer::tag('input', '', $inputattrs);
$cellcontent .= html_writer::tag('label', $choice, array(
'for' => "comment-{$item->id}-$i",
'class' => 'mod-ojt-topic-item-selection-label',
'style' => 'cursor:pointer'
));
$cellcontent .= html_writer::end_tag('span');
}
$cellcontent .= html_writer::end_tag('span');

Expand Down Expand Up @@ -265,7 +276,7 @@ function user_ojt(stdClass $userojt, bool $evaluate = false, bool $signoff = fal
$cellcontent = '';
if ($itemwitness) {
$witnessicon = $item->witnessedby ? 'completion-manual-y' : 'completion-manual-n';
$cellcontent .= html_writer:: start_tag('span', array('class' => 'ojt-witness-item', 'ojt-item-id' => $item->id));
$cellcontent .= html_writer:: start_tag('span', array('class' => 'ojt-witness-item', 'ojt-item-id' => $item->id, 'style' => 'cursor: pointer'));
$cellcontent .= $this->output->flex_icon($witnessicon, ['classes' => 'ojt-witness-toggle']);
$cellcontent .= html_writer::end_tag('div');

Expand Down Expand Up @@ -298,8 +309,10 @@ function user_ojt(stdClass $userojt, bool $evaluate = false, bool $signoff = fal
$out .= html_writer::start_tag('div', array('class' => 'mod-ojt-topic-signoff', 'ojt-topic-id' => $topic->id));
$out .= get_string('managersignoff', 'ojt');
if ($signoff) {
$out .= html_writer::start_tag('span', ['style' => 'cursor: pointer']);
$out .= $this->output->flex_icon($topic->signedoff ? 'completion-manual-y' : 'completion-manual-n',
['classes' => 'ojt-topic-signoff-toggle']);
$out .= html_writer::end_tag('span');
} else {
if ($topic->signedoff) {
$out .= $this->output->flex_icon('check-success', ['alt' => get_string('signedoff', 'ojt')]);
Expand Down
9 changes: 9 additions & 0 deletions uploadfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@

$fileoptions = $FILEPICKER_OPTIONS;
$fileoptions['maxfiles'] = 10;
$fileoptions['accepted_types'] = array(
'video',
'audio',
'archive',
'spreadsheet',
'presentation',
'document',
'image',
);

$item = new stdClass();
$item->topicitemid = $topicitemid;
Expand Down