async function uploadFile(file, g_id, directory) {
    const url = buildCourseUrl(['notebook_builder', 'file']);

    const form_data = new FormData();
    form_data.append('csrf_token', csrfToken);
    form_data.append('g_id', g_id);
    form_data.append('directory', directory);
    form_data.append('operation', 'upload');
    form_data.append('file', file, file.name);

    const response = await fetch(url, {method: 'POST', body: form_data});
    const result = await response.json();

    if (result.status === 'success') {
        console.log(`Successfully uploaded ${file.name}.`);
    }
    else {
        displayErrorMessage(`An error occurred uploading ${file.name}.  Check browser developer console for details.`);
        console.error(result.message);

        if (result.data && Array.isArray(result.data)) {
            result.data.forEach(msg => console.error(msg));
        }
    }
}
/**
 * Asynchronous upload of configuration dependency file.
 * These would typically be files that go in the 'test_input' or 'test_output' directory
 *
 * @param {File} file The file to be uploaded.
 * @param {string} g_id Gradeable ID
 * @param {string} directory The directory the file should be uploaded into.  Example would be 'test_input' or
 *                           'test_output'.
 * @returns {Promise}
 */
Asynchronous upload of configuration dependency file.
These would typically be files that go in the 'test_input' or 'test_output' directory

@param {File} file The file to be uploaded.
@param {string} g_id Gradeable ID
@param {string} directory The directory the file should be uploaded into.
Asynchronous upload of configuration dependency file . These would typically be files that go in the ' test_input ' or ' test_output ' directory @param { File } file The file to be uploaded . @param { string } g_id Gradeable ID @param { string } directory The directory the file should be uploaded into .
async function uploadFile(file, g_id, directory) {
    const url = buildCourseUrl(['notebook_builder', 'file']);
    const form_data = new FormData();
    form_data.append('csrf_token', csrfToken);
    form_data.append('g_id', g_id);
    form_data.append('directory', directory);
    form_data.append('operation', 'upload');
    form_data.append('file', file, file.name);
    const response = await fetch(url, {method: 'POST', body: form_data});
    const result = await response.json();
    if (result.status === 'success') {
        console.log(`Successfully uploaded ${file.name}.`);
    }
    else {
        displayErrorMessage(`An error occurred uploading ${file.name}.  Check browser developer console for details.`);
        console.error(result.message);
        if (result.data && Array.isArray(result.data)) {
            result.data.forEach(msg => console.error(msg));
        }
    }
}
async function uploadFile ( file , g_id , directory ) { const url = buildCourseUrl ( [ 'notebook_builder' , 'file' ] ) ; const form_data = new FormData ( ) ; form_data . append ( 'csrf_token' , csrfToken ) ; form_data . append ( 'g_id' , g_id ) ; form_data . append ( 'directory' , directory ) ; form_data . append ( 'operation' , 'upload' ) ; form_data . append ( 'file' , file , file . name ) ; const response = await fetch ( url , { method : 'POST' , body : form_data } ) ; const result = await response . json ( ) ; if ( result . status === 'success' ) { console . log ( ` ${ file . name } ` ) ; } else { displayErrorMessage ( ` ${ file . name } ` ) ; console . error ( result . message ) ; if ( result . data && Array . isArray ( result . data ) ) { result . data . forEach ( msg => console . error ( msg ) ) ; } } }
Asynchronous upload of configuration dependency file.
Asynchronous upload of configuration dependency file .