Skip to content

Commit

Permalink
Merge pull request #63 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
UpdateMaster
  • Loading branch information
Haward Ketoyo authored Jun 24, 2021
2 parents 85e0867 + df0b899 commit 5e10006
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 68 deletions.
4 changes: 2 additions & 2 deletions instat/dlgInfill.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 35 additions & 35 deletions instat/dlgInfill.resx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@
<data name="&gt;&gt;lblLimits.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="ucrDtpStartDate.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 45</value>
</data>
<data name="ucrDtpStartDate.Size" type="System.Drawing.Size, System.Drawing">
<value>200, 20</value>
</data>
<data name="ucrDtpStartDate.TabIndex" type="System.Int32, mscorlib">
<value>27</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Name" xml:space="preserve">
<value>ucrDtpStartDate</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Type" xml:space="preserve">
<value>instat.ucrDateTimePicker, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Parent" xml:space="preserve">
<value>grpOptions</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="lblStartingFrom.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
Expand Down Expand Up @@ -238,27 +259,6 @@
<value>grpOptions</value>
</data>
<data name="&gt;&gt;lblStartingFrom.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="ucrChkCompleteYears.Location" type="System.Drawing.Point, System.Drawing">
<value>16, 47</value>
</data>
<data name="ucrChkCompleteYears.Size" type="System.Drawing.Size, System.Drawing">
<value>194, 20</value>
</data>
<data name="ucrChkCompleteYears.TabIndex" type="System.Int32, mscorlib">
<value>34</value>
</data>
<data name="&gt;&gt;ucrChkCompleteYears.Name" xml:space="preserve">
<value>ucrChkCompleteYears</value>
</data>
<data name="&gt;&gt;ucrChkCompleteYears.Type" xml:space="preserve">
<value>instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;ucrChkCompleteYears.Parent" xml:space="preserve">
<value>grpOptions</value>
</data>
<data name="&gt;&gt;ucrChkCompleteYears.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="ucrChkResort.Location" type="System.Drawing.Point, System.Drawing">
Expand Down Expand Up @@ -325,7 +325,7 @@
<value>4</value>
</data>
<data name="ucrDtpEndDate.Location" type="System.Drawing.Point, System.Drawing">
<value>70, 72</value>
<value>71, 72</value>
</data>
<data name="ucrDtpEndDate.Size" type="System.Drawing.Size, System.Drawing">
<value>200, 20</value>
Expand All @@ -352,7 +352,7 @@
<value>NoControl</value>
</data>
<data name="lblEndDate.Location" type="System.Drawing.Point, System.Drawing">
<value>5, 76</value>
<value>12, 76</value>
</data>
<data name="lblEndDate.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 13</value>
Expand Down Expand Up @@ -405,25 +405,25 @@
<data name="&gt;&gt;lblStartDate.ZOrder" xml:space="preserve">
<value>8</value>
</data>
<data name="ucrDtpStartDate.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 45</value>
<data name="ucrChkCompleteYears.Location" type="System.Drawing.Point, System.Drawing">
<value>16, 47</value>
</data>
<data name="ucrDtpStartDate.Size" type="System.Drawing.Size, System.Drawing">
<value>200, 20</value>
<data name="ucrChkCompleteYears.Size" type="System.Drawing.Size, System.Drawing">
<value>194, 20</value>
</data>
<data name="ucrDtpStartDate.TabIndex" type="System.Int32, mscorlib">
<value>27</value>
<data name="ucrChkCompleteYears.TabIndex" type="System.Int32, mscorlib">
<value>34</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Name" xml:space="preserve">
<value>ucrDtpStartDate</value>
<data name="&gt;&gt;ucrChkCompleteYears.Name" xml:space="preserve">
<value>ucrChkCompleteYears</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Type" xml:space="preserve">
<value>instat.ucrDateTimePicker, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<data name="&gt;&gt;ucrChkCompleteYears.Type" xml:space="preserve">
<value>instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.Parent" xml:space="preserve">
<data name="&gt;&gt;ucrChkCompleteYears.Parent" xml:space="preserve">
<value>grpOptions</value>
</data>
<data name="&gt;&gt;ucrDtpStartDate.ZOrder" xml:space="preserve">
<data name="&gt;&gt;ucrChkCompleteYears.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<data name="grpOptions.Location" type="System.Drawing.Point, System.Drawing">
Expand Down
32 changes: 16 additions & 16 deletions instat/dlgInfill.vb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Public Class dlgInfill
ucrReceiverFactors.strSelectorHeading = "Factors"
ucrReceiverFactors.SetParameter(New RParameter("factors", 5))
ucrReceiverFactors.SetParameterIsString()
ucrReceiverFactors.strSelectorHeading = "Factors"

'Set data frame parameter
ucrInfillSelector.SetParameter(New RParameter("data_name", 0))
Expand Down Expand Up @@ -84,19 +83,13 @@ Public Class dlgInfill
ucrInputComboMonth.SetDropDownStyleAsNonEditable()
ucrInputComboMonth.SetLinkedDisplayControl(lblStartingFrom)

ucrDtpStartDate.SetParameter(New RParameter("start_date", 3))
ucrDtpStartDate.SetParameterIsRDate()

ucrDtpEndDate.SetParameter(New RParameter("end_date", 4))
ucrDtpEndDate.SetParameterIsRDate()

ucrChkCompleteYears.SetText("Ensure complete years")
ucrChkCompleteYears.AddParameterPresentCondition(True, "start_month")
ucrChkCompleteYears.AddParameterPresentCondition(False, "start_month", False)

ucrInputLimitOptions.AddToLinkedControls(ucrChkCompleteYears, {"Data Limits"}, bNewLinkedHideIfParameterMissing:=True)
ucrInputLimitOptions.AddToLinkedControls(ucrDtpStartDate, {"Fixed Start Limit", "Fixed Limits"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrInputLimitOptions.AddToLinkedControls(ucrDtpEndDate, {"Fixed End Limit", "Fixed Limits"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrInputLimitOptions.AddToLinkedControls(ucrDtpStartDate, {"Fixed Start Limit", "Fixed Limits"}, bNewLinkedHideIfParameterMissing:=True)
ucrInputLimitOptions.AddToLinkedControls(ucrDtpEndDate, {"Fixed End Limit", "Fixed Limits"}, bNewLinkedHideIfParameterMissing:=True)
ucrChkCompleteYears.AddToLinkedControls(ucrInputComboMonth, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="January")
ucrDtpEndDate.SetLinkedDisplayControl(lblEndDate)
ucrDtpStartDate.SetLinkedDisplayControl(lblStartDate)
Expand All @@ -120,11 +113,7 @@ Public Class dlgInfill
End Sub

Private Sub TestOkEnabled()
If Not (ucrReceiverDate.IsEmpty) Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
ucrBase.OKEnabled(Not ucrReceiverDate.IsEmpty)
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand All @@ -133,7 +122,18 @@ Public Class dlgInfill
TestOkEnabled()
End Sub

Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverFactors.ControlContentsChanged, ucrReceiverDate.ControlContentsChanged
Private Sub ucrInputLimitOptions_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputLimitOptions.ControlValueChanged, ucrDtpStartDate.ControlValueChanged, ucrDtpEndDate.ControlValueChanged
clsDefaultFunction.RemoveParameterByName("start_date")
clsDefaultFunction.RemoveParameterByName("end_date")
Select Case ucrInputLimitOptions.GetText
Case "Fixed Limits", "Fixed Start Limit"
clsDefaultFunction.AddParameter("start_date", clsRFunctionParameter:=ucrDtpStartDate.ValueAsRDate, iPosition:=3)
Case "Fixed Limits", "Fixed End Limit"
clsDefaultFunction.AddParameter("end_date", clsRFunctionParameter:=ucrDtpEndDate.ValueAsRDate, iPosition:=4)
End Select
End Sub

Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverDate.ControlContentsChanged
TestOkEnabled()
End Sub
End Class
End Class
4 changes: 2 additions & 2 deletions instat/instat.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="TranslateWinForm, Version=0.1.1.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TranslateWinForm.1.1.2\lib\net461\TranslateWinForm.dll</HintPath>
<Reference Include="TranslateWinForm, Version=0.1.1.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TranslateWinForm.1.1.3\lib\net461\TranslateWinForm.dll</HintPath>
</Reference>
<Reference Include="UIAutomationProvider" />
<Reference Include="unvell.ReoGrid, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion instat/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<package id="System.Data.SQLite.Core" version="1.0.113.7" targetFramework="net461" />
<package id="System.Security.AccessControl" version="4.5.0" targetFramework="net461" />
<package id="System.Security.Principal.Windows" version="4.5.0" targetFramework="net461" />
<package id="TranslateWinForm" version="1.1.2" targetFramework="net461" />
<package id="TranslateWinForm" version="1.1.3" targetFramework="net461" />
<package id="unvell.ReoGrid.dll" version="2.1.0.0" targetFramework="net451" />
</packages>
5 changes: 3 additions & 2 deletions instat/static/InstatObject/R/Rsetup.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ load_R_Instat_packages <- function() {
# wakefield because many functions do not work without loading (https://github.com/trinker/wakefield/issues/11)
# latticeExtra because conditionalQuantile key positions work well when latticeExtra is loaded
# texmex loaded because of extreme value distributions
packs_to_load <- c("plyr", "dplyr", "ggplot2", "ggthemes", "svglite", "ggfortify", "PCICt", "sp", "ggmosaic", "wakefield", "circular", "latticeExtra", "texmex")
# tidyr loaded because unite() function is required by mmtable() function from mmtable2 package
packs_to_load <- c("plyr", "tidyr", "dplyr", "ggplot2", "ggthemes", "svglite", "ggfortify", "PCICt", "sp", "ggmosaic", "wakefield", "circular", "latticeExtra", "texmex")
for(pack in packs_to_load) {
try(library(pack, character.only = TRUE))
}
Expand All @@ -222,4 +223,4 @@ source("data_object_R6.R")
source("labels_and_defaults.R")
source("stand_alone_functions.R")
files <- sort(dir(file.path(getwd(), 'Backend_Components/'), pattern=".R$", full.names = TRUE, recursive = TRUE))
invisible(lapply(files, source, chdir = TRUE))
invisible(lapply(files, source, chdir = TRUE))
7 changes: 5 additions & 2 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,9 @@ DataSheet$set("public","infill_missing_dates", function(date_name, factors, star
col_name <- factors[i]
col_names_exp[[i]] <- lazyeval::interp(~ var, var = as.name(col_name))
}
all_factors <- self$get_columns_from_data(factors, use_current_filter = FALSE)
first_factor <- self$get_columns_from_data(factors[1], use_current_filter = FALSE)
if(dplyr::n_distinct(interaction(all_factors, drop = TRUE))!= dplyr::n_distinct(first_factor)) stop("The multiple factor variables are not in sync. Should have same number of levels.")
grouped_data <- self$get_data_frame(use_current_filter = FALSE) %>% dplyr::group_by_(.dots = col_names_exp)
date_ranges <- grouped_data %>% dplyr::summarise_(.dots = setNames(list(lazyeval::interp(~ min(var), var = as.name(date_name)), lazyeval::interp(~ max(var), var = as.name(date_name))), c("min_date", "max_date")))
date_lengths <- grouped_data %>% dplyr::summarise(count = n())
Expand All @@ -2821,8 +2824,8 @@ DataSheet$set("public","infill_missing_dates", function(date_name, factors, star
full_dates_list <- list()
for(j in 1:nrow(date_ranges)) {
full_dates <- seq(date_ranges$min_date[j], date_ranges$max_date[j], by = "day")
if(length(full_dates) > date_lengths[[2]][j]) {
cat(paste(unlist(date_ranges[1:length(factors)][j, ]), collapse = "-"), ": Added", (length(full_dates) - date_lengths[[2]][j]), "rows to extend data and fill date gaps", "\n")
if(length(full_dates) > date_lengths[,"count"][j,]) {
cat(paste(unlist(date_ranges[1:length(factors)][j, ]), collapse = "-"), ": Added", (length(full_dates) - unlist(date_lengths[,"count"][j,])), "rows to extend data and fill date gaps", "\n")
merge_required <- TRUE
}
full_dates <- data.frame(full_dates)
Expand Down
Loading

0 comments on commit 5e10006

Please sign in to comment.