Exemple #1
0
        public void UpdateProgressDetailsForStoreAspProgressV2_updates_correct_fields_on_progress_record()
        {
            using var transaction = new TransactionScope();

            // Given
            const int    progressId              = 261317;
            const int    customisationVersion    = 1;
            var          submittedTime           = new DateTime(2022, 1, 1, 1, 1, 1);
            const string progressText            = "Test progress text";
            const int    diagnosticScore         = 100;
            var          expectedProgressDetails = new ProgressDetails(
                customisationVersion,
                submittedTime,
                progressText,
                diagnosticScore
                );

            // When
            progressDataService.UpdateProgressDetailsForStoreAspProgressV2(
                progressId,
                customisationVersion,
                submittedTime,
                progressText
                );

            // Then
            var progressDetails = progressTestHelper.GetProgressDetailsByProgressId(progressId);

            progressDetails.Should().BeEquivalentTo(expectedProgressDetails);
        }
    private IEnumerator GetCropProgress()
    {
        //Get users progress to display appropriate stage of crop
        string url = "http://127.0.0.1:5000/progresses/?student_id=" + PlayerPrefs.GetString("userID");

        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
        {
            yield return(webRequest.SendWebRequest());

            studentProgress = JsonUtility.FromJson <ProgressDetails>(webRequest.downloadHandler.text);
            for (int i = 0; i < 6; i++)
            {
                crops[i].GetComponent <Crop>().topicID = studentProgress.topics[i].id - 1;
                cropsText[i].text = studentProgress.topics[i].name;
                if (studentProgress.topics[i].completed_lessons == 0)
                {
                    crops[i].GetComponent <Image>().sprite = crops[i].GetComponent <Crop>().zeroImage;
                }
                else if (studentProgress.topics[i].completed_lessons == 1)
                {
                    crops[i].GetComponent <Image>().sprite = crops[i].GetComponent <Crop>().firstImage;
                }
                else if (studentProgress.topics[i].completed_lessons == 2)
                {
                    crops[i].GetComponent <Image>().sprite = crops[i].GetComponent <Crop>().secondImage;
                }
                else if (studentProgress.topics[i].completed_lessons == 3)
                {
                    crops[i].GetComponent <Image>().sprite = crops[i].GetComponent <Crop>().thirdImage;
                }
            }
        }
    }
Exemple #3
0
        public void ReportDetail(string detailMessage)
        {
            if (string.IsNullOrEmpty(this._currentMessage))
            {
                throw new Exception("Current message not set. Call Report() first.");
            }

            var rep = new ProgressDetails {
                Percentage = this._currentPercentage, Message = $"{this._currentMessage} [{detailMessage}]", Caption = this._caption
            };

            this.OnReport(rep);
            this.OnReportEmited(rep);
        }
Exemple #4
0
        public void Report(string message = null)
        {
            if (message != null)
            {
                this._currentMessage = message;
            }

            var rep = new ProgressDetails {
                Percentage = this._currentPercentage, Message = message, Caption = this._caption
            };

            this.OnReport(rep);
            this.OnReportEmited(rep);
        }
 /// <summary>
 /// Sends a progress update event to the user.
 /// </summary>
 /// <param name="sourceId">The source ID of the progress event.</param>
 /// <param name="progressDetails">The details of the activity's current progress.</param>
 protected override void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
 }
Exemple #6
0
 protected virtual void OnReportEmited(ProgressDetails progress) => this.ReportEmited?.Invoke(this, new ProgressDetailsEventArgs(progress));
Exemple #7
0
 void IConsoleHost.UpdateProgress(long sourceId, ProgressDetails progressDetails)
 {
     //throw new NotImplementedException();
 }
Exemple #8
0
 void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
     // TODO: Log progress
 }
 void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
     // TODO: Log progress
 }
        public async Task Execute(
            Func <CancellationToken, Task> function,
            string progressMessage                    = "",
            string successMessage                     = "",
            string failMessage                        = "",
            bool showProgress                         = true,
            bool rethrowUnhandledException            = true,
            bool isCancellationSupported              = true,
            CancellationToken?customCancellationToken = null)
        {
            try
            {
                if (showProgress)
                {
                    IsBusy          = true;
                    ProgressMessage = progressMessage;
                }

                ProgressDetails.Clear();
                IsCancellationSupported = isCancellationSupported;

                if (CancellationTokenSource.IsCancellationRequested)
                {
                    CancellationTokenSource?.Dispose();
                    CancellationTokenSource = new CancellationTokenSource();
                }

                CancellationToken cancellationToken = customCancellationToken ?? CancellationTokenSource.Token;

                await function(cancellationToken);

                if (!string.IsNullOrEmpty(successMessage))
                {
                    MessageQueue.Enqueue(successMessage);
                }
            }
            catch (TaskCanceledException)
            {
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, exception.Message);

                MessageQueue.Enqueue(
                    string.IsNullOrEmpty(failMessage)
                                                ? exception.Message
                                                : failMessage,
                    "Open Logs",
                    () => EventAggregator.PublishOnUIThreadAsync(new OpenLogsEvent()));

                if (rethrowUnhandledException)
                {
                    throw;
                }
            }
            finally
            {
                if (showProgress)
                {
                    IsBusy = false;
                }
            }
        }
Exemple #11
0
 void IConsoleHost.UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
     // TODO: Implement message for this
 }