File:  [LON-CAPA] / capa / capa51 / GUITools / ideas / of5tool / export.tcl
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Sep 28 21:26:14 1999 UTC (24 years, 11 months ago) by albertel
Branches: capa
CVS tags: start
Created directory structure

proc export {} {
    global problem

    set file [ tk_getSaveFile -defaultextension .qz \
		  -filetypes {{{Quizzer file} {.qz}}}  ]
    if { $file == "" } {
	tk_messageBox -icon info -type ok -message "Information not saved"
	return
    }
    
    set fileid [open $file "w"]
    
    exportQZHeader $fileid

    for { set i 1 } { $i <= $problem(num) } { incr i } {
	switch $problem(prob.$i.type) {
	    "Multiple Choice" 
	    {
		MCexportHeader $fileid $i
		MCexportLeafs $fileid $i
		MCexportAns $fileid $i 
	    }
	    -
	    {
		tk_messageBox -icon error \
	         -message "Problem type $problem(prob.$i.type) not supported" \
		    -type ok
	    }
	}
    }

    exportQZFooter $fileid 

    close $fileid
    
    tk_messageBox -icon info -message "Exported to $file" -type ok
}

proc exportQZHeader { fileid } {
    global problem

    puts $fileid "//Created by HACK GUI to qz files"
    puts $fileid "//CAPA system software is copyrighted by Michigan State University."
    puts $fileid "//"
    puts $fileid "/IMP \"../Tools/StdMacros\""
    puts $fileid "/IMP \"../Tools/StdUnits\""
    if { $problem(includes) != "" } {
    }
    puts $fileid "/IMP \"HWTop\""
}

proc exportQZFooter { fileid } {
    global problem

    puts $fileid "//*********************"
    puts $fileid "/END($problem(endline))"
}


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>