Created
May 14, 2020 15:49
-
-
Save kuldeep198811/774337226ce8db5c056c36f7cf9eff70 to your computer and use it in GitHub Desktop.
New Gist Code Review #1 for PHP Engineer at SkyVerge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'] ); ?> %</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