1300 12 12 64 hello@tadc.com.au
App Developer Skills Test

Please answer the following questions to the best of your availability. This is a skills test to gauge your level and knowledge. If you are not sure on how to answer a particular question, leave the answer blank. Please do not guess.

C#

Please review the following code and fix any errors:

bool CheckPassword(string Username, string Password)
{
    bool PasswordOk = false;
    using (SqlConnection con = new SqlConnection(conString))
    {
        con.Open();
        using (SqlCommand cmd = new SqlCommand("Select userkey from users where " +
            "username=" + Username + " and password=" + Password, con))
        {
            using (SqlDataReader DR = cmd.ExecuteReader())
            {
                if (DR.HasRows)
                {
                    DR.Read();
                    PasswordOk = true;
                }
            }
        }
    }
}

PHP

Please review the following code and explain its function. How would you improve this code?:

public function SampleFunction($method, $data = false) {

    $url="https://netapi.biterite.app";
    $curl = curl_init();

    switch ($method)
    {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
            if ($data) {
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                                'Content-Type: application/json',
                                'Content-Length: ' . strlen($data))
                );
            }
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            //GET
            if ($data)
                $url = sprintf("%s%s", $url, $data);
    }

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($curl);

    curl_close($curl);
    return $result;
}

XAML

Please review the following code and explain its function:

XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App.Controls.Test"
             x:Name="this">
    <Border StrokeThickness="2"
            StrokeShape="RoundRectangle 10,10,10,10"
            Background="{StaticResource Gray50}"
            Stroke="{StaticResource Gray300}"
            StrokeDashArray="3,3"
            StrokeDashOffset="1"
            MinimumHeightRequest="125"
            >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" ></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.GestureRecognizers>
                <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"></TapGestureRecognizer>
            </Grid.GestureRecognizers>
            <ActivityIndicator x:Name="aiLoading" 
                               IsRunning="true" IsVisible="false" 
                               VerticalOptions="CenterAndExpand" 
                               HorizontalOptions="CenterAndExpand"></ActivityIndicator>
            <Label x:Name="lblSelectImage"
            Text="+" FontSize="48"
            VerticalOptions="CenterAndExpand" 
            HorizontalOptions="CenterAndExpand" />
            <Image x:Name="imgShow" IsVisible="false" Aspect="AspectFill" MaximumHeightRequest="150">
            </Image>

        </Grid>
    </Border>
</ContentView>

C#

public partial class Test : ContentView
{

    public static readonly BindableProperty FileNameProperty = BindableProperty.Create(nameof(FileName), typeof(string), typeof(PhotoSelect), string.Empty);

    public string FileName
    {
        get => (string)GetValue(PhotoSelect.FileNameProperty);
        set => SetValue(PhotoSelect.FileNameProperty, value);
    }

    public Test()
    {
        InitializeComponent();
    }

    bool HasImage = false;

    public async Task LoadImage(long PhotoNumber)
    {
        FirstbaseUser User = Globals.User;
        HasImage = true;
        aiLoading.IsVisible = true;
        imgShow.IsVisible = false;
        lblSelectImage.IsVisible = false;
        string JR = await API_CALL($"v1/app/GetUserProfilePhoto/{User.SID}/{PhotoNumber}");
        UserProfileImage IMG = JsonConvert.DeserializeObject(JR);
        imgShow.Source = ImageSource.FromStream(() => new MemoryStream(IMG.ImgData));
        aiLoading.IsVisible = false;
        imgShow.IsVisible = true;
    }

    private async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
    {
        if (!HasImage)
        {
            if (MediaPicker.Default.IsCaptureSupported)
            {
                FileResult photo = await MediaPicker.Default.PickPhotoAsync();

                if (photo != null)
                {
                    FileName = photo.FullPath;
                    HasImage = true;
                    lblSelectImage.IsVisible = false;
                    try
                    {
                        var byteArray = File.ReadAllBytes(photo.FullPath);
                        imgShow.Source = ImageSource.FromStream(() => new MemoryStream(byteArray));
                        imgShow.IsVisible = true;
                    }
                    catch (Exception ex)
                    {

                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                }
            }
        }
        else
        {
            HasImage = false;
            lblSelectImage.IsVisible = true;
            imgShow.IsVisible = false;
            imgShow.Source = "";
            FileName = "";
        }
    }
}

SQL

Please review the following SQL, explain its function:

insert into subscriptions (user_id,stripe_plan,quantity,ends_at,created_at, updated_at,stripe_status)
select id,'premium',1,'2022-10-17 00:00:00',NOW(),NOW(),'' from users where last_plan_expires < '2022-10-01';

HTML/CSS

Please review the following and answer the following question:

<style>
.container {
	background-color: red;
	color: red !important;
 }
 
div {
	background-color: blue;
	color: orange;
}
	
p {
	background-color: yellow;
	color: blue;
}
</style>
<div class="container">
	<div>
		<h1>Title</h1>
		<p>Text</p>
	</div>
</div>

Profile

There are no right or wrong answers to the following questions.