StarkSoft Question Bank Management System (2) -- generate a word-format exam and Question Bank Management System
I. Functions
1. Customize the directory, difficulty level, question type, and knowledge base of the test database management system.
2. Enter questions.
3. Powerful question editing functions, which are common to common application editing tools.
4. Flexible exam construction function. You can customize exam title, exam category, question quantity, total score, and question Difficulty coefficient.
5. The format of manually generated and automatically generated exam documents is standard and common. It can be properly used, effectively edited, and saved for convenient browsing and output.
6. Question Bank management, which allows you to distribute and centrally manage question bank data at any time.
Ii. menu functions
1. Basic data maintenance: Question classification settings; question type settings; difficulty levels; Knowledge Point Library settings
2. Question Bank Management: Question entry
3. Exam management: manual exam generation; automatic exam generation; exam Database Management
Export exam to WORD
#region Create word test paper (export directly to word)
/// <summary>
/// create word test paper
/// </ summary>
/// <param name = "PathName"> </ param>
public void CreateWordFile (string PathName)
{
try
{
Object Nothing = System.Reflection.Missing.Value;
object filename = PathName; // File save path
// 1. Create Word document
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass ();
Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Add (ref Nothing, ref Nothing, ref Nothing, ref Nothing);
// 2. Add header
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
WordApp.ActiveWindow.ActivePane.Selection.InsertAfter ("[Entry Exam Paper]");
WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight; // Set right alignment
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument; // Exit header settings
WordApp.Selection.ParagraphFormat.LineSpacing = 8f; // Set the line spacing of the document
// 3. Move focus and wrap
object count = 14;
object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine; // Change one line;
WordApp.Selection.MoveDown (ref WdLine, ref count, ref Nothing); // Move focus
WordApp.Selection.TypeParagraph (); // Insert paragraph
#region title
WordApp.Selection.Font.Size = 20;
WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter; // Centered
WordApp.Selection.Font.Bold = 1; // bold
WordApp.Selection.TypeText ("Great Wall Information Entry Test");
WordApp.Selection.TypeParagraph ();
//WordApp.Selection.TypeParagraph ();
#endregion
// Set content format
WordApp.Selection.Font.Size = 12;
WordApp.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; // Centered
WordApp.Selection.Font.Bold = 0; // bold
string sql = @ "select * from base_tx";
DataTable dt = DataBaseAccess.GetDataTable (sql);
for (int i = 0; i <dt.Rows.Count; i ++)
{
// write title
WordApp.Selection.TypeText ((i + 1) + "," + dt.Rows [i] ["name"]. ToString () + "(3 points per question)" + "\ n \ n");
int txid = Convert.ToInt32 (dt.Rows [i] ["id"]); // Title ID
DataRow [] rows = dtxz.Select ("xztxid =" + txid, "xztxid asc");
DataTable dttemp = dtxz.Clone ();
dttemp.Clear ();
foreach (DataRow dr2 in rows)
{
dttemp.Rows.Add (dr2.ItemArray);
}
for (int k = 0; k <dttemp.Rows.Count; k ++)
{
string sqlstr = @ "select * from base_st where id =" + dttemp.Rows [k] ["xzstid"] + "";
DataTable dtst = DataBaseAccess.GetDataTable (sqlstr);
// Get title content
byte [] bWrite = (byte []) dtst.Rows [0] ["contents"]; // Read data from the database
string s = System.Text.Encoding.UTF8.GetString (bWrite, 0, bWrite.Length);
// start writing
WordApp.Selection.TypeText (s);
}
}
WordDoc.Paragraphs.Last.Range.Text = "Document creation time:" + DateTime.Now.ToString (); // "Sales"
WordDoc.Paragraphs.Last.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
// File save
WordDoc.SaveAs (ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); MessageBoxEx.Show ("Export succeeded!", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBoxEx.Show ("Export failed!" + "\ N" + ex.Message, "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
Complete source code download: http://www.51aspx.com/Code/StarkSoftExam
When the word automatically generates a directory, the entire segment is always written into the directory, and the text format is still like this. What should I do?
The automatic directory generation function of word saves us a lot of time, but if the operation is not good, it will be counterproductive-A waste of time. To be honest, I used to dislike the automatic numbering and other functions of word, so all the automatic functions of word are disabled. But I still use the automatic directory occasionally. However, if you use the "Title 1" and "title 2" in the "style" of word "... it will be very troublesome and there will be a black dot in front of the title (I am very uncomfortable !!!), Therefore, I will find a simple way to communicate with you.
(Assume that you have completed all the input of the document !)
1. At the beginning of the document, select the text content of the level-1 title you want to set, and set the font, font size, and other formats, select "format"-"section"-"indent and spacing" tab in the menu-and set "outline level" to level 1! (Key Steps !) -"OK ". (Note: In this process, the text to be set as a level-1 title is always selected! Haha, it is superfluous ^ 0 ^, but sometimes it will be ignored .) In this way, the first level title is set. In the same way, you can set level 2 and level 3... titles. The difference is to select level 2 and level 3 in "outline level.
2. Then it's easy. Use the level-1 title you just set to refresh Other level-1 titles (why? Ask someone else !), Other levels of titles and so on.
3. Place the cursor at the position where you want to insert a directory (usually before the document ), click "insert"-"Reference"-"index and directory"-"format" (the default value is "from template", but there is no leading character at this time. You can select "classical" first ", select "display page number" and "right-aligned page number", and select a "prefix "), select the maximum directory level you have set before for "display level" on the right (which can be small but not many !), Finally, press "OK "!! OK.
4. However, don't be too happy. You may find that the automatically generated directory is not in the same format as you think, for example, the line spacing is too large and the font size is too small. At this time, You can reset the directory. Move the cursor to any position in front of the Directory and repeat the previous "insert"-"Reference"-"index and directory". At this time, you will find that the "format" is changed to "from template ", click "modify" on the right. In the displayed dialog box, modify "directory 1" and "directory 2 "... they are actually corresponding to the level 1 and level 2 titles in your directory... after the modification, press "OK" to bring up "replace selected directory" and select "yes "! OK !!!
5. If the line spacing of a directory is too large or too small, you can only select all directories and set "line spacing" in "format"-"section", just like editing the body, no.
The younger brother is now using C # as a form of "Question Bank Management System". How can he save a WORD question to the database for urgent use?
It is not easy to give the code, but you can give a rough idea. If you want to store an entire question to the database, such as the WORD format you just mentioned, you can store it in binary format. For the answer, get another WORD document. If you want to analyze every question in the database, or if the question content is any combination, it will be a little complicated and you need to store the questions in the database, A corresponding answer is required for each question. The stored rules can be divided by single choice, multiple choices, fill in the blanks, and Q &.