Skip to content

Commit

Permalink
Merge pull request sakaiproject#763 from master-bob/SAM-2586
Browse files Browse the repository at this point in the history
SAM-2586 Add Side Panel to Track Question Progress
  • Loading branch information
jonespm committed Sep 30, 2015
2 parents bb358c1 + 1ca0b2a commit 8d151bb
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ public void setPrevious(boolean previous)
//Settings
public String getQuestionLayout()
{
if(getSettings().isFormatByQuestion()) {
questionLayout = "1";
}
else if (getSettings().isFormatByPart()) {
questionLayout = "2";
}
else if (getSettings().isFormatByAssessment()) {
questionLayout = "3";
}

return questionLayout;
}

Expand Down Expand Up @@ -1847,8 +1857,20 @@ public String saveAndExit(boolean needToCheck)
// removeTimedAssessmentFromQueue();
return returnValue;
}

public String next_page()
{

return next_helper(false);
}

public String goto_question()
{
return next_helper(true);
}


private String next_helper(boolean isGoToQuestion)
{
String nextAction = checkBeforeProceed();
log.debug("***** next Action="+nextAction);
Expand All @@ -1859,14 +1881,14 @@ public String next_page()
forGrade = false;

if (this.actionMode == TAKE_ASSESSMENT
|| this.actionMode == TAKE_ASSESSMENT_VIA_URL)
|| this.actionMode == TAKE_ASSESSMENT_VIA_URL)
{
syncTimeElapsedWithServer();

SubmitToGradingActionListener listener =
new SubmitToGradingActionListener();
new SubmitToGradingActionListener();
try {
listener.processAction(null);
listener.processAction(null);
}
catch (FinFormatException e) {
log.debug(e.getMessage());
Expand All @@ -1877,23 +1899,40 @@ public String next_page()
return "takeAssessment";
}
}


int oPartIndex = partIndex;
int oQuestionIndex = questionIndex;

if (getSettings().isFormatByPart())
{
partIndex++;
String partIndexString = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("partnumber");
if(isGoToQuestion) {
partIndex = Integer.parseInt(partIndexString);
} else {
partIndex++;
}
}
if (getSettings().isFormatByQuestion())
{
questionIndex++;

String questionIndexString = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("questionnumber");
if(isGoToQuestion) {
questionIndex = Integer.parseInt(questionIndexString);
} else {
questionIndex++;
}
}

DeliveryActionListener l2 = new DeliveryActionListener();
l2.processAction(null);


if ("1".equals(navigation) && this.actionMode != PREVIEW_ASSESSMENT) {
LinearAccessDeliveryActionListener linearAccessDeliveryActionListener = new LinearAccessDeliveryActionListener();
linearAccessDeliveryActionListener.saveLastVisitedPosition(this, partIndex, questionIndex);
LinearAccessDeliveryActionListener linearAccessDeliveryActionListener = new LinearAccessDeliveryActionListener();
if(isGoToQuestion) {
linearAccessDeliveryActionListener.saveLastVisitedPosition(this, oPartIndex, oQuestionIndex);
} else {
linearAccessDeliveryActionListener.saveLastVisitedPosition(this, partIndex, questionIndex);
}
}
reload = false;
return "takeAssessment";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,10 @@ private void goToRightQuestionFromTOC(DeliveryBean delivery) throws
{
if (ContextUtil.lookupParam("partnumber") != null &&
!ContextUtil.lookupParam("partnumber").trim().equals("") &&
!ContextUtil.lookupParam("partnumber").trim().equals("null") &&
ContextUtil.lookupParam("questionnumber") != null &&
!ContextUtil.lookupParam("questionnumber").trim().equals(""))
!ContextUtil.lookupParam("questionnumber").trim().equals("") &&
!ContextUtil.lookupParam("questionnumber").trim().equals("null"))
{
delivery.setPartIndex(Integer.valueOf
(ContextUtil.lookupParam("partnumber")).intValue() - 1);
Expand Down
89 changes: 88 additions & 1 deletion samigo/samigo-app/src/webapp/css/tool_sam.css
Original file line number Diff line number Diff line change
Expand Up @@ -1059,4 +1059,91 @@ ul.no-list {
td.feedbackColumn2 {
vertical-align: bottom;
padding-bottom: 15px;
}
}

#questionProgressPanel {
min-height: 200px;
max-height:auto;
width: 295px;
background: #ddd;
right:0px;
display: none;
position: fixed;
border: 2px solid #004B8D;
padding-bottom: 1em;
}
#questionProgressClick {
height: 200px;
width: 40px;
background: #004B8D;
right:299px;
margin-top: 200px;
position: fixed;
display: none;
font-weight: bold;
-moz-border-radius-topleft: 15px;
border-top-left-radius: 15px;
-moz-border-radius-bottomleft: 15px;
border-bottom-left-radius: 15px;
cursor: pointer;
}
.currentQuestion {
border: 1px solid #004B8D;
padding: 2px;
background-color:#d6ebff;
border-radius: 2px;
}
.questionProgressTable {

}
.questionProgressTable td {
border: 1px solid #ddd;
text-align: right;
background-color: #ddd;
}
.questionProgressTable td:hover {
background-color: #d6ebff;
border-color: #d6ebff;
cursor: pointer;
}
.questionProgressTable a {
text-decoration: none;
font-size:100%;
padding: 4px;
}
.questionProgressTable a img {
vertical-align: middle;
}
img.bublecenter {
vertical-align: middle;
}
p.progressItem {
padding:0 0 0 0;
margin:0 0 0 0;
line-height:1.5em;
}
p.progressItem img {
vertical-align: middle;
}

.rotateQP {
color:white;
white-space:nowrap;
margin-top:154px;

/* Safari */
-webkit-transform: rotate(-90deg);

/* Firefox */
-moz-transform: rotate(-90deg);

/* IE */
-ms-transform: rotate(-90deg);

/* Opera */
-o-transform: rotate(-90deg);

/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samigo/samigo-app/src/webapp/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions samigo/samigo-app/src/webapp/js/questionProgress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!-- Javascript for the Question Progress Panel-->
(function (questionProgress, $, undefined) {
var origWrapWidth = 0;
var CLICK_PANEL_WIDTH = 299;
var QP_ENABLED = true;
$('#questionProgressClick').click(function () {
toggle(400);
setQPToggleOn(!getQPToggleOn());
});

function toggle(animateTimer) {
var QPToggleOn = getQPToggleOn();
var wrapWidth = document.getElementById("delivAssessmentWrapper").offsetWidth;
var clickWidth = document.getElementById("questionProgressClick").offsetWidth;
var panelWidth = CLICK_PANEL_WIDTH;
var newWrapWidth = (wrapWidth - clickWidth) - panelWidth;
var clickHeight = $("#questionProgressClick").height();
var panelHeight = $("#questionProgressPanel").height();

if (!QPToggleOn) {
origWrapWidth = wrapWidth;
}
else {
origWrapWidth = wrapWidth + clickWidth + panelWidth;
}

$("#qpOpen").toggle();
$("#qpClose").toggle();
$("#questionProgressPanel").toggle("slide", {direction: "right"});
var panelHeight = $("#questionProgressPanel").height();

// Position the clickTab
if (!QPToggleOn) {
$("#questionProgressClick").animate({marginTop: 0, right: panelWidth}, animateTimer);
$("#delivAssessmentWrapper").animate({width: newWrapWidth}, animateTimer);
}
else {
$("#questionProgressClick").animate({marginTop: 0, right: 0}, animateTimer);
$("#delivAssessmentWrapper").animate({width: origWrapWidth}, animateTimer);
}
}

function getQPToggleOn() {
var value = localStorage.getItem('QPToggleOn');
return value == '1';
}

function setQPToggleOn(QPToggleOn) {
localStorage.setItem('QPToggleOn', (QPToggleOn ? '1' : '0'));
}

// This method transposes the table of contents table from displaying everything in one column to
// rather display in a more space efficient table with 10 columns per row.
questionProgress.transposeTOCTables = function() {
var MAXCOLUMNS = 5;
var tableList = document.getElementsByTagName("table");
for (var i = 0; i < tableList.length; i++) { // loop thru all tables to find the ones we want
if (tableList[i].id.indexOf("tocquestions") > 0) {
var oldTable = document.getElementById(tableList[i].id);
var newTable = document.createElement("table");

var colCount = 0;
var newRowCount = 0;
var colCount = 0;

newTable.insertRow(newRowCount); // create row
for (var oldRowCount = 0; oldRowCount < oldTable.rows.length; oldRowCount++) {
newTable.rows[newRowCount].insertCell(colCount); // create cell

// Set new cell equal to what was in the old row
var cellText = oldTable.rows[oldRowCount].cells[0].innerHTML; // always just one column in the original rows

newTable.rows[newRowCount].cells[colCount].innerHTML = cellText; // drop the dot.
colCount++;

if (colCount > (MAXCOLUMNS - 1)) { // reset & go to next row in new table
newRowCount++;
colCount = 0;
newTable.insertRow(newRowCount); //create new row
}
}
var temp = oldTable.ownerDocument.createElement('div');
temp.innerHTML = '<table>' + newTable.innerHTML + '</table>';
temp.firstChild.id = oldTable.id;
temp.firstChild.className += oldTable.className;
oldTable.parentNode.replaceChild(temp.firstChild, oldTable);
}// end if tab.id
} //end tableList for
};

// Make sure the main content area isn't initially too wide for the Question Progress
// Panel to display.
questionProgress.setUp = function() {
if (QP_ENABLED) {
var wrapWidth = document.getElementById("delivAssessmentWrapper").offsetWidth;
var clickWidth = document.getElementById("questionProgressClick").offsetWidth;
var newWrapWidth = (wrapWidth - clickWidth) - CLICK_PANEL_WIDTH;
var clickPos = 0;

if (!getQPToggleOn()) {
document.getElementById('qpOpen').style.display = "none";
document.getElementById('qpClose').style.display = "block";
document.getElementById('questionProgressPanel').style.display = "none";
document.getElementById('questionProgressClick').style.right = 0;
newWrapWidth = newWrapWidth + CLICK_PANEL_WIDTH;
} else {
document.getElementById('qpOpen').style.display = "block";
document.getElementById('qpClose').style.display = "none";
document.getElementById('questionProgressClick').style.display = "block";
document.getElementById('questionProgressPanel').style.display = "block";
}

document.getElementById('delivAssessmentWrapper').style.width = newWrapWidth + "px";
document.getElementById('questionProgressClick').style.marginTop = clickPos + "px";
}

};

// Hide Question Progress panel if strict linear nav. Also hide if there's more than one question on the page
questionProgress.access = function(navigation, layout) {
if (navigation == '2' && layout == '1') {
document.getElementById('questionProgressClick').style.display = "block";
} else {
$("#questionProgressClick").hide();
$("#questionProgressPanel").hide();
QP_ENABLED = false;
}
};

questionProgress.disableLink = function(link) {
link.style.display = 'none';
link.parentNode.firstChild.style.display = 'block';
return true;
};
}( window.questionProgress = window.questionProgress || {}, jQuery )) ;
Loading

0 comments on commit 8d151bb

Please sign in to comment.