<commit_before><?php

include_once 'check_access_permissions.php';
mustHaveAnyOfTheseRoles( array( 'AWS_ADMIN' ) );

include_once 'database.php';
include_once 'tohtml.php';
include_once 'methods.php';

echo userHTML( );

// Manage courses. Add into course_registration.
if( $_POST[ 'response' ] == 'submit' )
{
    $_POST[ 'last_modified_on' ] = dbDateTime( 'now' );
    $res = insertIntoTable( 'course_registration'
                , 'student_id,semester,year,type,course_id,registered_on,last_modified_on'
                , $_POST );

    if( $res )
    {
        echo printInfo( "You are successfully registered for the course" );
        goBack( 'user_manages_courses.php', 1 );
        exit;
    }
    else
    {
        echo minionEmbarrassed( "Failed to register you for the course." );
        echo printWarning( "Most likely you are already registered for this course" );
    }
    
}
else if( $_POST[ 'response' ] == 'drop' )
{
    // Drop this course.
    echo printInfo( "Dropping course " . $_POST[ 'course_id' ] );
    $_POST[ 'student_id' ] = $_SESSION[ 'user' ];
    $res = deleteFromTable( 'course_registration'
                        , 'student_id,semester,year,course_id'
                        , $_POST ); 
    if( $res )
        echo printInfo( "Successfully dropped course." );
    else
        echo minionEmbarrassed( "Failed to drop course" );
}

else
    echo alertUser( 'Unknown type of request ' . $_POST[ 'response' ] );

echo goBackToPageLink( "admin_acad_manages_enrollments.php", "Go back" );

?><commit_msg>Drop the course for given user.<commit_after><?php

include_once 'check_access_permissions.php';
mustHaveAnyOfTheseRoles( array( 'AWS_ADMIN' ) );

include_once 'database.php';
include_once 'tohtml.php';
include_once 'methods.php';

echo userHTML( );

// Manage courses. Add into course_registration.
if( $_POST[ 'response' ] == 'submit' )
{
    $_POST[ 'last_modified_on' ] = dbDateTime( 'now' );
    $res = insertIntoTable( 'course_registration'
                , 'student_id,semester,year,type,course_id,registered_on,last_modified_on'
                , $_POST );

    if( $res )
    {
        echo printInfo( "You are successfully registered for the course" );
        goBack( 'user_manages_courses.php', 1 );
        exit;
    }
    else
    {
        echo minionEmbarrassed( "Failed to register you for the course." );
        echo printWarning( "Most likely you are already registered for this course" );
    }
    
}
else if( $_POST[ 'response' ] == 'drop' )
{
    // Drop this course for given user.
    $res = deleteFromTable( 'course_registration'
                        , 'student_id,semester,year,course_id'
                        , $_POST ); 
    if( $res )
        echo printInfo( "Successfully dropped course." );
    else
        echo minionEmbarrassed( "Failed to drop course" );
}

else
    echo alertUser( 'Unknown type of request ' . $_POST[ 'response' ] );

echo goBackToPageLink( "admin_acad_manages_enrollments.php", "Go back" );

?>
{'fraction_non_alphanumeric': 0.1247082360786929, 'fraction_numerical': 0.0006668889629876625, 'mean_word_length': 2.865979381443299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7236705', 'n_tokens_mistral': 961, 'n_tokens_neox': 932, 'n_words': 236}