• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Print TEB's using Javascript - Issue with Print Window URL

New Here ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Hi everyone - ok, here's the mission......

I have a module that will be hosted on a LMS which has a number of Notes pages spread throughout the module. On each Notes page there are 2 or 3 questions with Text Entry Boxes available for users to provide responses (Each TEB has a variable assigned) . 

I have a button at the end of the module that executes javascript to get the responses provided in the TEB's and then create a document with those responses that can be printed. In essence, I have simply modified a version of eLearning Bros js - HERE.

All works well in IE11 and Chrome until a certain point.  It appears as though the javascript is adding every question and answer to the URL - (example below) at which point I receive a HTTP 404 error.

http://Myserver/Mycontent/Mycourseware/Mymodule/printpage.html?=Notes~~What%20part%20of%20the%20cycl...    etc etc etc etc...........

Appears as though receiving error due to maximum being reached of 2083 characters in total across the 23 TEB's. Have seen on the web that there is a limitation with length of URLs for different browsers.

Is there anything I can do / add to the javascript or amend the javascript to shorten, or remove the questions and answers from the URL ?

I have added the javascript I am using to the end of this thread

All help GREATFULLY received !

 

JAVASCRIPT

var header = "Notes~~"

var args =(

"What part of the cycle is your team good at ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_1')+

"~~What part of the cycle could your team improve ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_could_your_team_improve_2')+

"~~Additional Notes~~" + 

window.cpAPIInterface.

getVariableValue('Additional_Notes1_3')+

"~~What part of the cycle is your team good at ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_4')+

"~~What part of the cycle could your team improve ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_could_your_team_improve_5')+

"~~Additional Notes~~" + 

window.cpAPIInterface.

getVariableValue('Additional_Notes2_6')+

"~~What part of the cycle is your team good at ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_7')+

"~~What part of the cycle could your team improve 8~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_could_your_team_improve_8')+

"~~Additional Notes~~" + 

window.cpAPIInterface.

getVariableValue('Additional_Notes2_9')+

"~~What actions will you commit to ?~~" + 

window.cpAPIInterface.

getVariableValue('What_actions_will_you_commit_to_10')+

"~~Additional Notes~~" + 

window.cpAPIInterface.

getVariableValue('Additional_Notes_11')+

"~~What part of the cycle is your team good at ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_12')+

"~~What wastes your time and resources ?~~" + 

window.cpAPIInterface.

getVariableValue('What_wastes_your_time_and_resources_13')+

"~~How are you doing against today's targets and why ?~~" + 

window.cpAPIInterface.

getVariableValue('How_are_you_doing_against_today_s_targets_and_why_14')+

"~~Do you have the right staff in the right places to meet demand ?~~" + 

window.cpAPIInterface.

getVariableValue('Do_you_have_the_right_staff_in_the_right_places_to_meet_demand_15')+

"~~What areas would you like to improve ?~~" + 

window.cpAPIInterface.

getVariableValue('What_areas_would_you_like_to_improve_16')+

"~~What are the key challenges you are currently facing and how can we solve them ?~~" + 

window.cpAPIInterface.

getVariableValue('What_are_the_key_challenges_you_are_currently_facing_and_how_can_we_solve_them_17')+

"~~Additional Notes~~" + 

window.cpAPIInterface.

getVariableValue('Additional_Notes_18')+

"~~DEFINE - what exactly is the problem you're facing. How will you know you have fixed it ?~~" + 

window.cpAPIInterface.

getVariableValue('DEFINE___what_exactly_is_the_problem_you_re_facing__How_will_you_know_you_have_fixed_it_19')+

"~~MEASURE - what facts do you know about it ?~~" + 

window.cpAPIInterface.

getVariableValue('MEASURE___what_facts_do_you_know_about_it_20')+

"~~ANALYSE - Why do you think this problem is occurring. Do you think this is the root cause ?~~" + 

window.cpAPIInterface.

getVariableValue('ANALYSE___Why_do_you_think_this_problem_is_occurring__Do_you_think_this_is_the_root_cause_23')

)

var url = ("printpage.html?="  + header + args);

window.open(url,"_blank","width=800,height=600,menubar=no");

Views

385

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

You don't need to pass the variables in the URL.

All of those variables will be available in the window.opener.window.cpAPIInterface.

getVariableValue('ANALYSE___Why_do_you_think_this_problem_is_occurring__Do_you_think_this_ is_the_root_cause_23');

So when you open the print page, call a function onLoad on get the variables then.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Many Thanks TLC - however, I am extremely green with javascript....some might say virginal

So are you saying I can remove all of the getVariableValue lines except the last one ?  Not sure I understand...and what would I write for the function onLoad to get the variables ?

Been trying to solve this for a few days....scoured the web without any luck and this is the last thing holding up publication of the module (and client starting to tap their fingers !) so your help is really appreciated....and if I could give you +1000 kudos points I would.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

If you don't know JavaScript it will be difficult. And I wouldn't use eLearning brothers script.

Since you are opening the window from a Captivate file, you can use a reference from the popup to the Captivate page in the window.opener.

You could actually build the page with the text of the questions already in it and then just populate the answers with script. I would name the variables in Captivate "answer_1, answer_2" and so on so they would be easy to reference or loop through.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

TLC means that you can change things like:

 

var args =(

"What part of the cycle is your team good at ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_1')+

"~~What part of the cycle could your team improve ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_could_your_team_improve_2')+

to:

var args =(

"Cycle good?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_is_your_team_good_at_1')+

"~~Cycle improve ?~~" + 

window.cpAPIInterface.

getVariableValue('What_part_of_the_cycle_could_your_team_improve_2')+

 

this really assumes that it is ok to shorten the questions on the printed page, and that even then, the text from the answer doesn't blow the 2000+ character limit. 

depending on your application,  there are different approaches to the desired result.   I'd probably go with using javascript to just open another window and write the questions  + answers directly to it.  I've looked at the elearningbrothers print.html script,  it is always going to have this problem.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources