Skip to content

Commit

Permalink
Minor bug fixes and features adjustments. (#154)
Browse files Browse the repository at this point in the history
- Fix #149 Guessing the registration URL allows circumventing the log start date bug
- Add direct-link search for Events (by system, branch, or search string)
- Add direct-link search for Challenges (by search string)
- Unify badge detail logic (was in two places)
- When badge details show an event, add a link to search for that event
- Fixed #153, "Award Name" should say "Avatar Name"
- Fixed #151, "Reading goal should only use points earned by reading"
- Fixed #52, Program flag "Allow Patron to enter book review" now provides field.
  • Loading branch information
justinmeiners authored and Harald Nagel committed May 5, 2016
1 parent 8fd1f03 commit 512183c
Show file tree
Hide file tree
Showing 20 changed files with 256 additions and 162 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,14 @@ All notable changes to this project will be documented in this file.
- `/Events/?System=<system name>` shows events for that library system
- `/Events?Search=<search string>` shows events with the provided search string
- `/Challenges?Search=<search string>` shows challenges with the provided search string
- #52 Add field to enter book details for book review. The field's visibilty is controlled by a program flag.
- Patron registration process now informs users about goal range.

### Changed
- #151 Reading goal now only accounts for points earned through reading instead of all point methods

### Fixed
- #153 Control room avatar editor now syas "Avatar name", instead of "Award NAme"

## [3.1.0] - 2016-04-27
### Added
Expand Down
1 change: 1 addition & 0 deletions GRA.Database/GRA.Database.sqlproj
Expand Up @@ -688,6 +688,7 @@
<Build Include="dbo\Stored Procedures\app_ProgramCodes_GetAllByTenantId.sql" />
<Build Include="dbo\Stored Procedures\rpt_ProgramByBranch.sql" />
<Build Include="dbo\Functions\fx_PatronBadgeCount.sql" />
<Build Include="dbo\Stored Procedures\app_PatronPoints_GetPatronReadingPoints.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Snapshots\GRA-2.2.1.dacpac" />
Expand Down
Expand Up @@ -22,6 +22,11 @@ INNER JOIN (
FROM PatronPoints pp
WHERE pp.PID = pt.PID
), 0) AS Points,
isnull((
SELECT isnull(SUM(isnull(NumPoints, 0)), 0)
FROM PatronPoints pp
WHERE pp.PID = pt.PID AND pp.AwardReasonCd = 0
), 0) AS ReadingPoints,
pt.TenID
FROM Patron pt
WHERE pt.PID = @PID
Expand All @@ -45,7 +50,7 @@ INNER JOIN (
AND (award.NumPoints <= patron.Points)
AND (
TotalGoal < 1
OR award.GoalPercent <= (patron.points * 100) / TotalGoal
OR award.GoalPercent <= (patron.ReadingPoints * 100) / TotalGoal
)
AND (
BadgeList = ''
Expand Down
Expand Up @@ -23,6 +23,11 @@ INNER JOIN (
FROM PatronPoints pp
WHERE pp.PID = pt.PID
), 0) AS Points,
isnull((
SELECT isnull(SUM(isnull(NumPoints, 0)), 0)
FROM PatronPoints pp
WHERE pp.PID = pt.PID AND pp.AwardReasonCd = 0
), 0) AS ReadingPoints,
@TenID AS TenID
FROM Patron pt
WHERE pt.PID = @PID
Expand All @@ -46,7 +51,7 @@ INNER JOIN (
AND (award.NumPoints <= patron.Points)
AND (
TotalGoal < 1
OR award.GoalPercent <= (patron.points * 100) / TotalGoal
OR award.GoalPercent <= (patron.ReadingPoints * 100) / TotalGoal
)
AND (
BadgeList = ''
Expand Down
@@ -0,0 +1,19 @@

/****** Object: StoredProcedure [dbo].[app_PatronPoints_GetPatronReadingPoints] Script Date: 01/05/2015 14:43:23 ******/
--Create the Insert Proc
CREATE PROCEDURE [dbo].[app_PatronPoints_GetPatronReadingPoints] (@PID INT)
AS
BEGIN
IF (
EXISTS (
SELECT isnull(SUM(isnull(NumPoints, 0)), 0) AS TotalPoints
FROM PatronPoints
WHERE PID = @PID AND AwardReasonCd = 0
)
)
SELECT isnull(SUM(isnull(NumPoints, 0)), 0) AS TotalPoints
FROM PatronPoints
WHERE PID = @PID AND AwardReasonCd = 0
ELSE
SELECT 0 AS TotalPoints
END
46 changes: 44 additions & 2 deletions SRP/ControlRoom/Modules/Install/CreateSchema.sql
Expand Up @@ -336,6 +336,11 @@ INNER JOIN (
FROM PatronPoints pp
WHERE pp.PID = pt.PID
), 0) AS Points,
isnull((
SELECT isnull(SUM(isnull(NumPoints, 0)), 0)
FROM PatronPoints pp
WHERE pp.PID = pt.PID AND pp.AwardReasonCd = 0
), 0) AS ReadingPoints,
pt.TenID
FROM Patron pt
WHERE pt.PID = @PID
Expand All @@ -359,7 +364,7 @@ INNER JOIN (
AND (award.NumPoints <= patron.Points)
AND (
TotalGoal < 1
OR award.GoalPercent <= (patron.points * 100) / TotalGoal
OR award.GoalPercent <= (patron.ReadingPoints * 100) / TotalGoal
)
AND (
BadgeList = ''
Expand Down Expand Up @@ -398,6 +403,11 @@ INNER JOIN (
FROM PatronPoints pp
WHERE pp.PID = pt.PID
), 0) AS Points,
isnull((
SELECT isnull(SUM(isnull(NumPoints, 0)), 0)
FROM PatronPoints pp
WHERE pp.PID = pt.PID AND pp.AwardReasonCd = 0
), 0) AS ReadingPoints,
@TenID AS TenID
FROM Patron pt
WHERE pt.PID = @PID
Expand All @@ -421,7 +431,7 @@ INNER JOIN (
AND (award.NumPoints <= patron.Points)
AND (
TotalGoal < 1
OR award.GoalPercent <= (patron.points * 100) / TotalGoal
OR award.GoalPercent <= (patron.ReadingPoints * 100) / TotalGoal
)
AND (
BadgeList = ''
Expand Down Expand Up @@ -8592,6 +8602,38 @@ BEGIN
END
GO



/****** Object: StoredProcedure [dbo].[app_PatronPoints_GetPatronReadingPoints] Script Date: 01/05/2015 14:43:23 ******/
--Create the Insert Proc

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[app_PatronPoints_GetPatronReadingPoints] (@PID INT)
AS
BEGIN
IF (
EXISTS (
SELECT isnull(SUM(isnull(NumPoints, 0)), 0) AS TotalPoints
FROM PatronPoints
WHERE PID = @PID AND AwardReasonCd = 0
)
)
SELECT isnull(SUM(isnull(NumPoints, 0)), 0) AS TotalPoints
FROM PatronPoints
WHERE PID = @PID AND AwardReasonCd = 0
ELSE
SELECT 0 AS TotalPoints
END

GO


/****** Object: StoredProcedure [dbo].[app_PatronPoints_Insert] Script Date: 2/4/2016 13:18:40 ******/
SET ANSI_NULLS ON
GO
Expand Down
4 changes: 2 additions & 2 deletions SRP/ControlRoom/Modules/Setup/AvatarAddEdit.aspx
Expand Up @@ -32,7 +32,7 @@
<EditItemTemplate>
<table>
<tr>
<td nowrap height="20px"><b>Award Name: </b></td>
<td nowrap height="20px"><b>Avatar Name: </b></td>
<td colspan="3">
<asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>' ReadOnly="False" Width="500px" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server"
Expand Down Expand Up @@ -71,7 +71,7 @@
<InsertItemTemplate>
<table>
<tr>
<td nowrap height="20px"><b>Award Name: </b></td>
<td nowrap height="20px"><b>Avatar Name: </b></td>
<td colspan="3">
<asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>' ReadOnly="False" Width="500px" CssClass="form-control"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server"
Expand Down
14 changes: 14 additions & 0 deletions SRP/Controls/FamilyReadingLogControl.ascx
Expand Up @@ -91,6 +91,20 @@
</div>
</div>
</div>
<% if (ViewState[PatronCanReviewKey] as bool? == true) { %>
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="form-group">
<label for="authorField">Review</label>
<asp:TextBox runat="server"
ID="reviewField"
TextMode="MultiLine"
CssClass="form-control"
style="resize: none;"></asp:TextBox>
</div>
</div>
</div>
<% } %>
</div>
<div class="modal-footer hidden-print">
<div class="pull-right clearfix">
Expand Down
28 changes: 21 additions & 7 deletions SRP/Controls/FamilyReadingLogControl.ascx.cs
Expand Up @@ -16,6 +16,9 @@ namespace GRA.SRP.Controls
public partial class FamilyReadingLogControl : System.Web.UI.UserControl
{
protected const string RequireBookDetailsKey = "RequireBookDetails";
protected const string PatronCanReviewKey = "PatronReviewFlag";
protected const string ProgramGameIdKey = "ProgramGameId";
protected const string SubmitAsPatronIdKey = "SubmitAsPatronId";

protected bool ShowModal { get; set; }
protected void Page_Load(object sender, EventArgs e)
Expand All @@ -29,7 +32,7 @@ protected void Page_Load(object sender, EventArgs e)
Response.Redirect("~");
}

ViewState["SubmitAsPatronId"] = familyRelationship.PatronId;
ViewState[SubmitAsPatronIdKey] = familyRelationship.PatronId;

var patron = Patron.FetchObject(familyRelationship.PatronId);
var program = Programs.FetchObject(patron.ProgID);
Expand All @@ -45,8 +48,9 @@ protected void Page_Load(object sender, EventArgs e)
}

ViewState[RequireBookDetailsKey] = program.RequireBookDetails;
ViewState[PatronCanReviewKey] = program.PatronReviewFlag;

ViewState["ProgramGameId"] = program.PID.ToString();
ViewState[ProgramGameIdKey] = program.PID.ToString();

if (Request.Cookies[CookieKey.LogBookDetails] != null)
{
Expand Down Expand Up @@ -113,7 +117,7 @@ protected void SubmitActivity()
var intCount = 0;
if (txtCount.Length == 0 || !int.TryParse(txtCount, out intCount) || intCount < 0)
{
Session[SessionKey.PatronMessage] = "You must enter how much was read as a positive whole number.";
Session[SessionKey.PatronMessage] = StringResources.getString("readinglog-entry-invalid");
Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Danger;
Session[SessionKey.PatronMessageGlyphicon] = "remove";
return;
Expand Down Expand Up @@ -142,16 +146,16 @@ protected void SubmitActivity()
}
if (intCount > maxAmountForLogging)
{
Session[SessionKey.PatronMessage] = string.Format("That's an awful lot of reading! You can only submit {0} {1} at a time.",
Session[SessionKey.PatronMessage] = string.Format(StringResources.getString("readinglog-entry-limit"),
maxAmountForLogging,
((ActivityType)int.Parse(selectedActivityType)).ToString());
Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning;
Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign";
return;
}

var patronId = int.Parse(ViewState["SubmitAsPatronId"].ToString());
var programGameId = int.Parse(ViewState["ProgramGameId"].ToString());
var patronId = int.Parse(ViewState[SubmitAsPatronIdKey].ToString());
var programGameId = int.Parse(ViewState[ProgramGameIdKey].ToString());
var patron = Patron.FetchObject(patronId);
var patronName = DisplayHelper.FormatName(patron.FirstName, patron.LastName, patron.Username);
var pa = new AwardPoints(patronId);
Expand All @@ -165,7 +169,7 @@ protected void SubmitActivity()
points = (int)Math.Ceiling(computedPoints);

// ensure they aren't over teh day total
var allPointsToday = PatronPoints.GetTotalPatronPoints(patronId, DateTime.Now);
var allPointsToday = PatronPoints.GetTotalPatronPointsOnDate(patronId, DateTime.Now);
int maxPointsPerDayForLogging = SRPSettings.GetSettingValue("MaxPtsDay").SafeToInt();
if (intCount + allPointsToday > maxPointsPerDayForLogging)
{
Expand All @@ -175,6 +179,13 @@ protected void SubmitActivity()
return;
}

var review = "";

if (ViewState[PatronCanReviewKey] as bool? == true)
{
review = reviewField.Text;
}

var earnedBadges = pa.AwardPointsToPatron(points: points,
reason: PointAwardReason.Reading,
MGID: 0,
Expand All @@ -193,6 +204,7 @@ protected void SubmitActivity()
}
authorField.Text = string.Empty;
titleField.Text = string.Empty;
reviewField.Text = string.Empty;

// set message and earned badges
string earnedMessage = new PointCalculation().EarnedMessage(earnedBadges, points, patronName);
Expand Down Expand Up @@ -232,6 +244,7 @@ protected void submitButton_Click(object sender, EventArgs e)
}
authorField.Text = string.Empty;
titleField.Text = string.Empty;
reviewField.Text = string.Empty;
SubmitActivity();
}
}
Expand All @@ -242,6 +255,7 @@ protected void cancelButton_Click(object sender, EventArgs e)
familyReadingLogPopup.Visible = false;
authorField.Text = string.Empty;
titleField.Text = string.Empty;
reviewField.Text = string.Empty;
}
protected void submitDetailsButton_Click(object sender, EventArgs e)
{
Expand Down
9 changes: 9 additions & 0 deletions SRP/Controls/FamilyReadingLogControl.ascx.designer.cs

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

2 changes: 1 addition & 1 deletion SRP/Controls/MyPointsControl.ascx
Expand Up @@ -5,7 +5,7 @@
<br />

<div id="divGoalProgress" runat="server" >
<span>Overall Goal</span>
<span><asp:Label ID="lblGoal" runat="server" Text="points-goal-label"></asp:Label></span>
<div class="progress" style="margin-left: 8px; margin-right: 8px">
<div ID="divGoalProgressBar" runat="server" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%; min-width: 2em;">
<asp:Label ID="lblPercentGoal" runat="server" Text="Label"></asp:Label>
Expand Down
4 changes: 3 additions & 1 deletion SRP/Controls/MyPointsControl.ascx.cs
Expand Up @@ -32,6 +32,8 @@ public partial class MyPointsControl : System.Web.UI.UserControl {
}
}


int readingPoints = PatronPoints.GetPatronReadingPoints(patron.PID);
RegistrationSettings settings = RegistrationSettings.FetchObject(patron.TenID);

if (settings.Goal_Show) {
Expand All @@ -43,7 +45,7 @@ public partial class MyPointsControl : System.Web.UI.UserControl {
/* avoid divide by zero */
if (totalGoal > 0)
{
percent = (totalPoints * 100) / totalGoal;
percent = (readingPoints * 100) / totalGoal;
}

String percentString = $"{percent}%";
Expand Down
9 changes: 9 additions & 0 deletions SRP/Controls/MyPointsControl.ascx.designer.cs

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

11 changes: 11 additions & 0 deletions SRP/Controls/PatronRegistration.ascx
Expand Up @@ -433,6 +433,16 @@
</asp:Panel>

<asp:Panel ID="Panel5" runat="server" Visible="False">

<asp:Panel runat="server" ID="RegistrationGoalInfoNote" CssClass="row" visible='<%# (bool)Eval("Goal_Prompt")%>'>
<div class="col-xs-12 col-sm-8 col-sm-offset-2 margin-1em-bottom">
<div class="alert alert-info">
<span class="glyphicon glyphicon-info-sign"></span>
<asp:Label runat="server" ID="RegistrationGoalInfoNoteLabel" Text="registration-goal-limits-note"></asp:Label>
</div>
</div>
</asp:Panel>

<asp:TextBox ID="Panel5Visibility" runat="server"
Text='<%# ((bool)Eval("PrimaryLibrary_Prompt") || (bool)Eval("LibraryCard_Prompt") || (bool)Eval("SchoolName_Prompt") || (bool)Eval("District_Prompt") || (bool)Eval("SDistrict_Prompt") || (bool)Eval("Teacher_Prompt") || (bool)Eval("GroupTeamName_Prompt") || (bool)Eval("SchoolType_Prompt") || (bool)Eval("LiteracyLevel1_Prompt") || (bool)Eval("LiteracyLevel2_Prompt") || (bool)Eval("Goal_Prompt") ? "1" : "0") %>'
Visible="false"></asp:TextBox>
Expand Down Expand Up @@ -568,6 +578,7 @@
</div>
</asp:Panel>


<div class="form-group" runat="server" visible='<%# (bool)Eval("Teacher_Prompt")%>'>
<label class="col-sm-3 control-label">
<asp:Label runat="server" Text="registration-form-teacher"></asp:Label>
Expand Down

0 comments on commit 512183c

Please sign in to comment.