Skip to content

Commit

Permalink
Merge pull request #16 from uriweb/release-1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
alexandragauss authored Jan 26, 2024
2 parents 254c4e8 + 3bdcd22 commit ba2c87c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

A tool that makes it easy to embed dynamic course data from Kuali.

## What's new in v1.3.0
## What's new in v1.4.0

- Adds a skip capability attribute, which allows the plugin to call the next 100 course entries.
- Adds multiple queries to call up to 300 courses in a given subject at a time.

## Example Usage

Expand All @@ -16,6 +16,6 @@ __Contributors:__ [bjcfuller](https://github.com/bjcfuller), [alexandragauss](ht
__Tags:__ plugins, shortcodes
__Requires at least:__ 5.0
__Tested up to:__ 6.0.2
__Stable tag:__ 1.3.0
__Stable tag:__ 1.4.0
__License:__ GPL-3.0
__Licence URI:__ https://www.gnu.org/licenses/gpl-3.0.html
33 changes: 29 additions & 4 deletions inc/uri-kuali-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ function uri_kuali_get_data( $url ) {
// otherwise, call the api, cache it, and return the data
//echo '<br />no cache for ' . uri_kuali_hash_string( $url );
//echo '<br />calling api...';


$data = uri_kuali_api_call( $url, uri_kuali_api_get_header() );
uri_kuali_cache_update( $url, $data );
return $data;


}

Expand Down Expand Up @@ -119,11 +122,33 @@ function uri_kuali_api_get_subject_data( $subject ) {
function uri_kuali_api_get_courses( $id, $atts ) {

$api_base = uri_kuali_get_api_base();

/* Build URL for a list of courses if a course number isn't specified */
/*
$url1 = $api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=' . $atts['limit'] . '&status=active&skip=' .$atts['skip'];
$url2 = $api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=100&status=active&skip=100';
$all_queries = array( $url1, $url2);
var_dump($all_queries);
foreach ($all_queries as $url ) {
return uri_kuali_get_data( $url );
}
*/
/* Build URL queries for a list of all courses in intervals of 100 if a course number isn't specified */
if (null === $atts['number']) {
$url = $api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=' . $atts['limit'] . '&status=active&skip=' .$atts['skip'];
return uri_kuali_get_data( $url );

$urls = array(
$api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=100&status=active&skip=',
$api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=100&status=active&skip=100',
$api_base . '/cm/courses/queryAll?subjectCode=' . $id . '&sort=number&limit=100&status=active&skip=200',
);

$getdata1 = uri_kuali_get_data( $urls[0] );
$getdata2 = uri_kuali_get_data( $urls[1] );
$getdata3 = uri_kuali_get_data( $urls[2] );

$course_list = (object)array_merge_recursive((array)$getdata1, (array)$getdata2, (array)$getdata3);

return $course_list;
}

/* If a course number is specified, build URL for single course */
Expand Down
4 changes: 2 additions & 2 deletions inc/uri-kuali-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function uri_kuali_shortcode( $attributes, $content, $shortcode ) {
'number' => NULL,
'before' => '<div class="uri-kuali">',
'after' => '</div>',
'limit' => 100, // 100 is the maximum Kuali will return with a single query. For more than that, @see https://developers.kuali.co/#cm-courses,-programs,-experiences,-and-specializations-query
'skip' => NULL,
//'limit' => 100, // 100 is the maximum Kuali will return with a single query. For more than that, @see https://developers.kuali.co/#cm-courses,-programs,-experiences,-and-specializations-query
//'skip' => NULL,
), $attributes, $shortcode );

$subject_data = uri_kuali_api_get_subject_data( $attributes['subject'] );
Expand Down
2 changes: 1 addition & 1 deletion uri-kuali.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: URI Kuali
Plugin URI: https://www.uri.edu
Description: Implements a shortcode to display course data from Kuali's API. [courses subject="AAF"]
Version: 1.3.0
Version: 1.4.0
Author: Brandon Fuller
Author: Alexandra Gauss
Author URI:
Expand Down

0 comments on commit ba2c87c

Please sign in to comment.