Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuldeep198811/774337226ce8db5c056c36f7cf9eff70 to your computer and use it in GitHub Desktop.
Save kuldeep198811/774337226ce8db5c056c36f7cf9eff70 to your computer and use it in GitHub Desktop.
New Gist Code Review #1 for PHP Engineer at SkyVerge
<?php
class courses extends users
{
/**
* sso link public varible
*/
public $sso_link;
/**
* This code retrieves course data from an external API and displays it in the user's
* My Account area. A merchant has noticed that there's a delay when loading the page.
*
* == What changes would you suggest to reduce or remove that delay? ==
*/
public function add_my_courses_section()
{
global $current_user;
$api_user_id = $this->get_user_meta( $current_user->ID, '_external_api_user_id', true );
if ( !$api_user_id )
{
return;
}
$this->sso_link = $this->get_api()->get_sso_link( $api_user_id );
$courses = $this->get_api()->get_courses_assigned_to_user( $api_user_id );
return $courses;
}
}
$objClassCourses = new courses();
?>
<h2 style="margin-top: 40px;"><?php print ( 'My Courses' ); ?></h2>
<?php if(!empty($objClassCourses->add_my_courses_section())){ ?>
<table>
<thead>
<tr>
<th><?php echo ( 'Course Code' ); ?></th>
<th><?php echo ( 'Course Title' ); ?></th>
<th><?php echo ( 'Completion' ); ?></th>
<th><?php echo ( 'Date Completed' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach( $objClassCourses->add_my_courses_section() as $course ) {?>
<tr>
<td><?php echo ( $course['Code'] ); ?></td>
<td><?php echo ( $course['Name'] ); ?></td>
<td><?php echo ( $course['PercentageComplete'] ); ?> &#37;</td>
<td><?php echo ( $course['DateCompleted'] ); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<p><a href="<?php echo $objClassCourses->sso_link ?>" target="_blank" class="button <?php echo $_GET['active_course']; ?>"><?php echo ( 'Course Login'); ?></a></p>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment