Skip to content

Commit

Permalink
Importer should work now with php5.1. Closes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Mar 8, 2011
1 parent 603ec39 commit a60a4e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions gradebook/bpsp-gradebook.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,25 @@ function import_gradebook_screen( $vars ) {
return $this->gradebook_screen( $vars );
}

$grades = array();
if( isset( $_FILES['csv_filename'] ) && !empty( $_FILES['csv_filename'] )) {
require_once 'parseCSV.class.php'; // Load CSV parser
$csv = new parseCSV();
$csv->auto( $_FILES['csv_filename']['tmp_name'] );
foreach ( $csv->data as &$grade ) {

foreach ( $csv->data as $grade ) {
$id = bp_core_get_userid_from_nicename( $grade['uid'] );
if( $id )
$csv->data[$id] = $grade;
unset( $grade );
$grades[$id] = $grade;
}
if( !empty( $csv->data ) ) {
$vars['grades'] = $csv->data;
if( count( $csv->data ) == count( $grades ) )
$vars['message'] = __( 'Data imported successfully, but it is not saved yet! Save this form changes to keep the data.', 'bpsp' );
$vars['assignment_permalink'] = $vars['assignment_permalink'] . '/gradebook';
}
else
$vars['error'] = __( 'File data contains error or entries from other gradebook. Please check again.', 'bpsp' );
}

$vars['grades'] = $grades;
$vars['assignment_permalink'] = $vars['assignment_permalink'] . '/gradebook';
unset( $_POST );
return $this->gradebook_screen( $vars );
}
Expand Down Expand Up @@ -493,4 +495,4 @@ function student_screen( $vars ) {
return $vars;
}
}
?>
?>
2 changes: 1 addition & 1 deletion responses/bpsp-responses.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,4 @@ function load_editor() {
wp_enqueue_script('media-upload', get_bloginfo('wpurl') . $media_upload_js, array( 'thickbox' ), filemtime( ABSPATH . $media_upload_js) );
}
}
?>
?>

0 comments on commit a60a4e9

Please sign in to comment.