Changeset dd227daa1d04…
Parent a3abb5320257…
by Rondell Hames <rondell.hames@nexportengineering.com>
Changes to 3 files · Browse files at dd227daa1d04 Showing diff from parent a3abb5320257 Diff from another changeset...
|
|
@@ -29,7 +29,7 @@ );
public static Regex TernaryBlockRegex = new Regex(
- "\\(\\s*((?:\\w|[().])+)\\s+if\\s+(.+)\\s+else\\s+(.+)\\s*\\)",
+ @"\(\s*((?:\w|[().""'])+)\s+if\s+(.+)\s+else\s+(.+)\s*\)",
RegexOptions.Singleline
| RegexOptions.CultureInvariant
| RegexOptions.Compiled
@@ -43,6 +43,20 @@ | RegexOptions.Compiled
);
+ public static Regex DateFormatComponentRegex = new Regex(
+ @"component\s+DateFormat\,\s*(\{.*\})\s*:\s*end",
+ RegexOptions.Singleline
+ | RegexOptions.CultureInvariant
+ | RegexOptions.Compiled
+ );
+
+ public static Regex Colon2EqualInDateFormatComponentRegex = new Regex(
+ @"\""([^""]*)\""\s*\:",
+ RegexOptions.Singleline
+ | RegexOptions.CultureInvariant
+ | RegexOptions.Compiled
+ );
+
public static Regex OutputSubviewSingleParamRegex = new Regex(
"OutputSubView\\s*\\(\\s*(\\\"[^\"]*\\\"\\s*)\\s*\\)",
RegexOptions.Singleline
@@ -147,33 +161,40 @@ private static SearchOption _allDirs;
private static bool _insideElement;
private static List<string> _imports;
+ private static string _singleFile;
- static void Main(string[] args)
+ static void Main(string[] args)
{
var p = new FluentCommandLineParser();
p.SetupHelp("?", "help")
.Callback(text => Console.WriteLine(text));
- p.Setup<string>('d', "directory")
- .WithDescription("The directory to scan for brail files.")
- .Callback(dir => _directory = dir)
- .Required();
+ p.Setup<string>('d', "directory")
+ .WithDescription("The directory to scan for brail files.")
+ .Callback(dir => _directory = dir)
+ .SetDefault(null)
+ ;
p.Setup<string>('e', "extension")
.WithDescription("The brail file extension. The default is .brail")
.Callback(ext => _extension = ext.StartsWith(".") ? ext.Substring(1) : ext)
.SetDefault("brail");
+ p.Setup<string>('f', "file")
+ .WithDescription("The brail file to convert.")
+ .Callback(file => _singleFile = file)
+ .SetDefault(null);
+
p.Setup<bool>('s', "subdirs")
.WithDescription("If set then the converter will include sub directories.")
.Callback(include => _allDirs = include ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
var result = p.Parse(args);
-
- if (result.HasErrors)
+
+ if (result.HasErrors || (!File.Exists(_singleFile) && !Directory.Exists(_directory)))
{
Console.WriteLine(result.ErrorText);
@@ -188,18 +209,35 @@ }
Console.WriteLine("Starting brail to razor conversion of directory {0}", _directory);
+ string[] files;
+ if (_singleFile != null)
+ {
+ files = new[] {_singleFile};
+ }
+ else
+ {
+ files = System.IO.Directory.GetFiles(_directory, "*." + _extension, _allDirs);
+ }
- var files = System.IO.Directory.GetFiles(_directory, "*." + _extension, _allDirs);
-
- foreach (var file in files)
+ foreach (var file in files)
{
- BrailConvert(file, Path.ChangeExtension(file, "cshtml"));
+ try
+ {
+ BrailConvert(file, Path.ChangeExtension(file, "cshtml"));
+ Console.WriteLine("SUCCESS: " + file + "\n");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("FAILED: " + file);
+ Console.WriteLine("Message: " + ex.Message);
+ }
+
}
}
private static void BrailConvert(string brailPath, string outPath)
{
- _imports = new List<string>();
+ _imports = new List<string>() { "using NexportVirtualCampus.Utilities" };
Console.WriteLine("Converting file {0}", brailPath);
string code;
@@ -252,10 +290,13 @@ break;
case "%>":
//Get rid of the extra stuff
- currentCodeBlock.Remove(currentCodeBlock.Length - 2,2);
- string converted = ConvertBrailBlockToRazor(currentCodeBlock.ToString());
- razorOut.Append(converted);
- currentCodeBlock.Clear();
+ if(currentCodeBlock.Length > 0)
+ {
+ currentCodeBlock.Remove(Math.Max(0, currentCodeBlock.Length - 2),2);
+ string converted = ConvertBrailBlockToRazor(currentCodeBlock.ToString());
+ razorOut.Append(converted);
+ currentCodeBlock.Clear();
+ }
codeLocation = CodeLocationEnum.NormalText;
break;
case "${":
@@ -278,7 +319,7 @@
if (previosChar == '<' && codeLocation == CodeLocationEnum.NormalText)
{
- // INSIDE AN ELEMENT
+ // INSIDE AN ELEMENTl
_insideElement = true;
}
@@ -288,7 +329,7 @@ }
//Add the imports
- var imports = String.Join(Environment.NewLine, _imports.Select(i => "@" + i + ";").ToArray());
+ var imports = String.Join(Environment.NewLine, _imports.Select(i => "@" + i).ToArray());
File.WriteAllText(outPath, imports + Environment.NewLine + razorOut.ToString());
}
@@ -305,7 +346,7 @@ finalResult = "</text>" + finalResult;
}
- else if (brail.Trim().Equals("else:"))
+ else if (brail.Trim().Equals("else:") || brail.Trim().Equals("else :"))
{
finalResult += "}else{";
if (_insideElement)
@@ -370,8 +411,14 @@ lineResult = NotIsNullRegex.Replace(lineResult, " $1 != null ");
lineResult = FixStandaloneNotRegex.Replace(lineResult, "!($1)");
lineResult = lineResult.Replace(" is null", " == null");
-
- lineResult = lineResult.Replace("ViewHelper.TableStripe()", "new HtmlTableStripePainter()");
+ lineResult = lineResult.Replace(" is !(", " != (");
+ if (DateFormatComponentRegex.IsMatch(lineResult))
+ {
+ lineResult = DateFormatComponentRegex.Replace(lineResult,
+ "Html.DisplayDate(new DisplayDateProperties()$1)");
+ lineResult = Colon2EqualInDateFormatComponentRegex.Replace(lineResult, "$1 = ");
+ }
+ lineResult = lineResult.Replace("ViewHelper.TableStripe()", "new HtmlTableStripePainter()");
if(lineResult.Trim() == "end")
lineResult = lineResult.Replace("end", "}");
@@ -388,6 +435,7 @@
if (NewLineRegex.IsMatch(finalResult))
{
+ //Multiline statement!
finalResult = finalResult.Trim();
if (finalResult[0] == '@')
finalResult = finalResult.Substring(1);
@@ -398,6 +446,9 @@ }
else
{
+ //Singleline Statement
+ //Change RenderPartial to just Partial
+ finalResult = finalResult.Replace("Html.RenderPartial", "Html.Partial");
finalResult = "@" + finalResult.Trim();
}
|
|
@@ -1,67 +1,106 @@ - <%
-import Nexport.Models
-import Nexport.Models.Assignments
+<% import System %>
+<% dialogTitle = 'Attempt ' + (attempt.AttemptIndex+1) + ' for ' + attempt.AssignmentStatus.Enrollment.Subscription.User.FormalName
+ score = (Math.Round(attempt.Score,0) if attempt.IsComplete else '-')
+ isLocked = assignment.IsTimedTest and attempt.IsComplete == false and attempt.IsWithinGracePeriod() == false and not attempt.AllowReLaunch
+ if score == '-':
+ if isLocked:
+ statusIcon = "lock"
+ else:
+ statusIcon = ""
+ end
+ else:
+ if score >= assignment.MasteryScore:
+ statusIcon = "validate-ok"
+ else:
+ statusIcon = "validate-fail"
+ end
+ end
-OutputSubView("WithSpace/DisplayITrainingDates")
-
+ canStudentReview = assignment.CanStudentReview and isInstructor == false and attempt.IsComplete and score >= assignment.MasteryScore
%>
-<% OutputSubView("WithSpace/DisplayITrainingDates") %>
-<div class="layout-percent">
- <div class="col width-1of2 right"><label>Is Academically Overridden?:</label></div>
- <div class="col last width-1of2 left"><label><% if item.AcademicOverride: %>!{commonText.yes}<% else: %>!{commonText.no}<% end %></label></div>
-</div>
-<div class="layout-percent">
- <div class="col width-1of2 right"><label>Academic Override By:</label></div>
- <div class="col last width-1of2 left"><label><% foo = (item.AcademicOverrideAdmin.FullName if item.AcademicOverride and not item.AcademicOverrideAdmin == null else "n/a") %>!{foo}</label></div>
-</div>
-
-<% if item.AcademicOverrideAdmin == null and not rt == rt :%>
-
+<td><span class="icon-only !{statusIcon}"> </span></td>
+<td>
+ <input type="hidden" class="identity" value="!{?attempt.Id}" />
+
+ ${attempt.AttemptIndex + 1}
+</td>
+<td>!{score}</td>
+<td>${TestHelper.AnsweredQuestionsCount(attempt)}/${attempt.NumQuestions}</td>
+<% if assignment.IsTimedTest: %><td>!{attempt.TimeLeftFormatted}</td><% end %>
+<td><% component DateFormat, { "Date": attempt.StartDate, "Format": "TerseDateTime", "DoShift": true }: end %></td>
+<td><% if attempt.FinishDate != null: %><% component DateFormat, { "Date": attempt.FinishDate, "Format": "TerseDateTime", "DoShift": true }: end %><% end %>
+ <% if canStudentReview : %>
+ <% showScript = "openAttemptDetails('${attempt.Id}');return false;"
+ showTitle = "Show attempt answers"
+ showIcon = "magnifier"
+ %>
+ <% OutputSubView ('..\\..\\Common\\UtilityBars\\ManageBar', {"Details": showScript, "DetailsTitle": showTitle }) %>
+<% end %>
+</td>
+<% if isInstructor: %>
+<td class="center">
+ <div class="managementBar">
+ <% showScript = "openAttemptDetails('${attempt.Id}');return false;"
+ showTitle = "Show attempt answers"
+ showIcon = "magnifier"
+ allowScript = ("allowRelaunch(this);return false;" if isLocked else "return false;")
+ allowTitle = "Allow the student to continue work on this attempt"
+ allowDisable = (false if isLocked else true)
+ allowIcon = ("lock-delete" if isLocked else "lock-delete-disabled")
+ endScript = ("endAttempt(this);return false;" if isLocked else "return false;")
+ endTitle = "Force the attempt to be complete"
+ endIcon = ("time-delete" if isLocked else "time-delete-disabled")
+ endDisable = (false if isLocked else true) %>
+ <% if assignment.IsTimedTest: %>
+ <% OutputSubView ('..\\..\\Common\\UtilityBars\\ManageBar', {"Details": showScript, "DetailsTitle": showTitle,
+ "Remove": allowScript, "RemoveTitle": allowTitle, "RemoveIcon": allowIcon,
+ "RemoveDisable": allowDisable, "BombDisable": endDisable,
+ "Bomb": endScript, "BombTitle": endTitle, "BombIcon": endIcon }) %>
+ <% else: %>
+ <% OutputSubView ('..\\..\\Common\\UtilityBars\\ManageBar', {"Details": showScript, "DetailsTitle": showTitle }) %>
+ <% end %>
+ </div>
+</td>
<% end %>
-<% if rondell is null:%>
+<script type="text/javascript">
+ var openAttemptDetails = function (attemptId) {
+ var specs = "toolbar=yes,location=no,directories=no,menubar=yes,scrollbars=yes";
+ window.open(siteRoot + '/TestAssignment/AttemptDetails.rails?attempt='+ attemptId,'_blank',specs);
+ }
-<% end %>
+ var allowRelaunch = function (element) {
+ if (!confirm("Are you sure you would like to allow the student to relaunch the timed test?"))
+ return;
+ $.ajax({
+ url: siteRoot + "/TestAssignment/AllowReLaunch.rails",
+ data: { 'attempt': $(element).closest('.testResultAttempt').find('.identity').val() },
+ success: function (html, status) {
+ // update the table row
+ $(element).closest('.testResultAttempt').html(html);
+ }
+ });
+ }
-<% if rondell is null :%>
+ var endAttempt = function (element) {
+ if (!confirm("Are you sure you would like to end the student's attempt?"))
+ return;
+ $.ajax({
+ url: siteRoot + "/TestAssignment/EndAttempt.rails",
+ data: { 'attempt': $(element).closest('.testResultAttempt').find('.identity').val() },
+ success: function (html, status) {
+ $(element).closest('.testResultAttempt').html(html);
+ }
+ });
+ }
+</script>
-<% end %>
-
-<% if item.AcademicOverrideAdmin == null and not rt == rt and not re != re.Tom() :%>
-
-<% end %>
-<% if item.AcademicOverrideAdmin == null and not rt == rt and not re != re.Eddie :%>
-
-<% end %>
-
-<% if not item.AcademicOverrideAdmin == null and rt == rt and not re != re.Eddie :%>
-
-<% end %>
-
-<% if item.AcademicOverrideAdmin == null and rt == rt :%>
-
-<% OutputSubView("templates/DisplayITrainingDates", {"item": assignmentStatus}) %>
- <% OutputSubView("templates/DisplayITrainingStatus", {"item": assignmentStatus}) %>
- <% OutputSubView("templates/DisplayITrainingAcademicOverride", {"item": assignmentStatus}) %>
- <% OutputSubView ("WithSpace/DisplayITrainingDates", {"item": assignmentStatus}) %>
-
-
- <button type="button" onclick="aoTool.overrideAssignmentStatus(this);"><span class="icon save">Override</span></button>
- <% disabled = ' disabled="disabled"'
- if not assignmentStatus is null and assignmentStatus.AcademicOverride:
- disabled = ''
- end
- %>
- <button type="button" onclick="aoTool.removeAssignmentStatusOverride(this);"${disabled}><span class="icon undo">Undo Override</span></button>
-
-
- <div class="col last width-1of2 left">
- <% if assignment.NameToken == "Assignments_Courseware": %>
- <button type="button"<% if not canImpersonate: %> disabled="disabled"<% else: %> onclick="window.open('!{realSlimShady}/Scorm/Impersonate.rails?assignment=!{assignment.Id}&enrollment=!{sectionEnrollment.Id}', 'Impersonate');"<% end %> >
- <span class="icon magnifier">${AdministrationText.Impersonate}</span>
- </button>
- <% end %>
- <button type="button" onclick="aoTool.deleteAssignmentStatus(this); return false;"><span class="icon bomb">Destroy</span></button>
- </div>
-
- <% end %>
\ No newline at end of file+ <% if status.Phase.ToString() == "ToBeGraded": %>
+<td style="font-weight:bold;">
+ ${EnumHelper.GetTranslation(status.Phase)}
+</td>
+<% else : %>
+<td>
+ ${EnumHelper.GetTranslation(status.Phase)}
+</td>
+<% end %>
\ No newline at end of file |
|
@@ -1,64 +1,117 @@ - @using Nexport.Models;
-@using Nexport.Models.Assignments;
-@Html.RenderPartial("WithSpace/DisplayITrainingDates")
-@Html.RenderPartial("WithSpace/DisplayITrainingDates")
-<div class="layout-percent">
- <div class="col width-1of2 right"><label>Is Academically Overridden?:</label></div>
- <div class="col last width-1of2 left"><label>@if(item.AcademicOverride){@commonText.yes}else{@commonText.no}</label></div>
-</div>
-<div class="layout-percent">
- <div class="col width-1of2 right"><label>Academic Override By:</label></div>
- <div class="col last width-1of2 left"><label>@foo = (item.AcademicOverride && !(item.AcademicOverrideAdmin == null) ? item.AcademicOverrideAdmin.FullName : "n/a")@foo</label></div>
-</div>
+@using NexportVirtualCampus.Utilities;
+@using System;
-@if(item.AcademicOverrideAdmin == null && !(rt == rt) ){
+@(dialogTitle = "Attempt " + (attempt.AttemptIndex+1) + " for " + attempt.AssignmentStatus.Enrollment.Subscription.User.FormalName;
+
+score = (Math.Round(attempt.Score,0) if attempt.IsComplete else "-");
+
+isLocked = assignment.IsTimedTest and attempt.IsComplete == false and attempt.IsWithinGracePeriod() == false and !(attempt.AllowReLaunch);
+
+if(score == "-"){
+if(isLocked){
+statusIcon = "lock";
+
+else:;
+
+statusIcon = "";
}
+else:;
-@if(rondell == null){
+if(score >= assignment.MasteryScore){
+statusIcon = "validate-ok";
+
+else:;
+
+statusIcon = "validate-fail";
}
+}
+canStudentReview = assignment.CanStudentReview and isInstructor == false and attempt.IsComplete and score >= assignment.MasteryScore)
+<td><span class="icon-only @statusIcon"> </span></td>
+<td>
+ <input type="hidden" class="identity" value="@?attempt.Id" />
+
+ @attempt.AttemptIndex + 1
+</td>
+<td>@score</td>
+<td>@TestHelper.AnsweredQuestionsCount(attempt)/@attempt.NumQuestions</td>
+@if(assignment.IsTimedTest){<td>@attempt.TimeLeftFormatted</td>}
+<td>@Html.DisplayDate(new DisplayDateProperties(){ Date = attempt.StartDate, Format = "TerseDateTime", DoShift = true })</td>
+<td>@if(attempt.FinishDate != null){@Html.DisplayDate(new DisplayDateProperties(){ Date = attempt.FinishDate, Format = "TerseDateTime", DoShift = true })}
+ @if(canStudentReview ){↵@showScript = "openAttemptDetails('${attempt.Id');return false;"
+ showTitle = "Show attempt answers"
+ showIcon = "magnifier"
+ %>
+ @OutputSubView ("..\\..\\Common\\UtilityBars\\ManageBar", {"Details": showScript, "DetailsTitle": showTitle })
+}
+</td>
+@if(isInstructor){
+<td class="center">
+ <div class="managementBar">↵@showScript = "openAttemptDetails('${attempt.Id');return false;"
+ showTitle = "Show attempt answers"
+ showIcon = "magnifier"
+ allowScript = ("allowRelaunch(this);return false;" if isLocked else "return false;")
+ allowTitle = "Allow the student to continue work on this attempt"
+ allowDisable = (false if isLocked else true)
+ allowIcon = ("lock-delete" if isLocked else "lock-delete-disabled")
+ endScript = ("endAttempt(this);return false;" if isLocked else "return false;")
+ endTitle = "Force the attempt to be complete"
+ endIcon = ("time-delete" if isLocked else "time-delete-disabled")
+ endDisable = (false if isLocked else true) %>
+ @if(assignment.IsTimedTest){
+ @(OutputSubView ("..\\..\\Common\\UtilityBars\\ManageBar", {"Details": showScript, "DetailsTitle": showTitle,;
-@if(rondell == null ){
+"Remove": allowScript, "RemoveTitle": allowTitle, "RemoveIcon": allowIcon,;
+"RemoveDisable": allowDisable, "BombDisable": endDisable,;
+
+"Bomb": endScript, "BombTitle": endTitle, "BombIcon": endIcon }))
+ }else{
+ @OutputSubView ("..\\..\\Common\\UtilityBars\\ManageBar", {"Details": showScript, "DetailsTitle": showTitle })
+ }
+ </div>
+</td>
}
-@if(item.AcademicOverrideAdmin == null && !(rt == rt && !(re != re.Tom())) ){
+<script type="text/javascript">
+ var openAttemptDetails = function (attemptId) {
+ var specs = "toolbar=yes,location=no,directories=no,menubar=yes,scrollbars=yes";
+ window.open(siteRoot + '/TestAssignment/AttemptDetails.rails?attempt='+ attemptId,'_blank',specs);
+ }
-}
-@if(item.AcademicOverrideAdmin == null && !(rt == rt && !(re != re.Eddie)) ){
+ var allowRelaunch = function (element) {
+ if (!confirm("Are you sure you would like to allow the student to relaunch the timed test?"))
+ return;
+ $.ajax({
+ url: siteRoot + "/TestAssignment/AllowReLaunch.rails",
+ data: { 'attempt': $(element).closest('.testResultAttempt').find('.identity').val() },
+ success: function (html, status) {
+ // update the table row
+ $(element).closest('.testResultAttempt').html(html);
+ }
+ });
+ }
-}
+ var endAttempt = function (element) {
+ if (!confirm("Are you sure you would like to end the student's attempt?"))
+ return;
+ $.ajax({
+ url: siteRoot + "/TestAssignment/EndAttempt.rails",
+ data: { 'attempt': $(element).closest('.testResultAttempt').find('.identity').val() },
+ success: function (html, status) {
+ $(element).closest('.testResultAttempt').html(html);
+ }
+ });
+ }
+</script>
-@if(!(item.AcademicOverrideAdmin == null )&& rt == rt && !(re != re.Eddie) ){
-
-}
-
-@if(item.AcademicOverrideAdmin == null && rt == rt ){
-
-@Html.RenderPartial("templates/DisplayITrainingDates",new ViewDataDictionary( new {item = assignmentStatus} ))
- @Html.RenderPartial("templates/DisplayITrainingStatus",new ViewDataDictionary( new {item = assignmentStatus} ))
- @Html.RenderPartial("templates/DisplayITrainingAcademicOverride",new ViewDataDictionary( new {item = assignmentStatus} ))
- @Html.RenderPartial("WithSpace/DisplayITrainingDates",new ViewDataDictionary( new {item = assignmentStatus} ))
-
-
- <button type="button" onclick="aoTool.overrideAssignmentStatus(this);"><span class="icon save">Override</span></button>
- @(disabled = " disabled=\"disabled\"";
-
-if( assignmentStatus != null && assignmentStatus.AcademicOverride){
-disabled = "";
-
-})
- <button type="button" onclick="aoTool.removeAssignmentStatusOverride(this);"@disabled><span class="icon undo">Undo Override</span></button>
-
-
- <div class="col last width-1of2 left">
- @if(assignment.NameToken == "Assignments_Courseware"){
- <button type="button"@if(!(canImpersonate)){<text> disabled="disabled"</text>}else{<text> onclick="window.open('@realSlimShady/Scorm/Impersonate.rails?assignment=@assignment.Id&enrollment=@sectionEnrollment.Id', 'Impersonate');"</text>} >
- <span class="icon magnifier">@AdministrationText.Impersonate</span>
- </button>
- }
- <button type="button" onclick="aoTool.deleteAssignmentStatus(this); return false;"><span class="icon bomb">Destroy</span></button>
- </div>
-
- }
\ No newline at end of file+ @if(status.Phase.ToString() == "ToBeGraded"){
+<td style="font-weight:bold;">
+ @EnumHelper.GetTranslation(status.Phase)
+</td>
+}else{
+<td>
+ @EnumHelper.GetTranslation(status.Phase)
+</td>
+}
\ No newline at end of file |
Loading...