Skip to content

Commit

Permalink
Fixing GitHub Action Warnings & Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
st143971 committed Aug 12, 2024
1 parent 3490ffb commit 3a2f936
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions amd/src/search_and_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ function getEachOccurrenceContextPosition(occurrences, wordIndexes, contextLengt
if (wordNumber + 1 >= wordIndexes.length) {
const start = Math.max(0, wordNumber - contextLength);
const length = null;
results.push({ start: start, end: length });
results.push({
start: start,
end: length
});
continue;
}

Expand Down Expand Up @@ -274,7 +277,6 @@ function getEachOccurrenceContextPosition(occurrences, wordIndexes, contextLengt
}



/**
* Returns the number of the last word still in the context. Returns null if the context is the rest of all words.
* @param {Array} wordIndexes An array that has the text starting index for each word.
Expand Down
18 changes: 9 additions & 9 deletions classes/search/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ private static function get_each_occurences_context_position($occurrences, $word
// The current occurence to check against.
$currentoccurence = $occurrences[$currentoccurrenceindex];

// This word is not (yet) important for the context
// This word is not (yet) important for the context.
if ($wordindexes[$wordnumber + 1] <= $currentoccurence->start) {
continue;
}

// This word begins an occurence
// This word begins an occurence.
$start = max(0, $wordnumber - $contextlength);
$end = self::get_context_end($wordindexes, $wordnumber, $currentoccurence->end, $contextlength);

Expand Down Expand Up @@ -260,22 +260,22 @@ private static function get_context_end($wordindexes, $startnumber, $endindex, $
* @return array An array of occurrence position objects, each with 'start' (first word number of context)
* and 'length' (number of words part of this occurence context, or null if at end of text) properties.
*/
private static function merge_occurence_context_positions($contextposition) {
private static function merge_occurence_context_positions($contextpositions) {
$results = [];

for ($i = 0; $i < count($contextposition); $i++) {
for ($i = 0; $i < count($contextpositions); $i++) {
// The first position.
$position = $contextposition[$i];
$position = $contextpositions[$i];
$start = $position->start;
$end = $position->end;

// Other positions.
while (
$i + 1 < count($contextposition) && // Check if there is a next position.
$contextposition[$i]->end && // Check if 'end' is null. We can then ignore all upcoming positions.
$contextposition[$i]->end >= $contextposition[$i + 1]->start // Check if this and the next positions overlap.
$i + 1 < count($contextpositions) && // Check if there is a next position.
$contextpositions[$i]->end && // Check if 'end' is null. We can then ignore all upcoming positions.
$contextpositions[$i]->end >= $contextpositions[$i + 1]->start // Check if this and the next positions overlap.
) {
$end = $contextposition[$i + 1]->end; // The positions overlap so the end gets set to ht next positions end.
$end = $contextpositions[$i + 1]->end; // The positions overlap so the end gets set to ht next positions end.
$i++;
}

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024081108; // The current plugin version (Date: YYYYMMDDHH).
$plugin->version = 2024081200; // The current plugin version (Date: YYYYMMDDHH).
$plugin->requires = 2020061510; // Requires this Moodle version.
$plugin->component = 'block_booksearch'; // Full name of the plugin (used for diagnostics).
$plugin->release = '1.1.3';
Expand Down

0 comments on commit 3a2f936

Please sign in to comment.