⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onlinetest.java

📁 简单的在线考试系统 提供添加修改 考试等操作
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/save.gif")));
			putValue(SHORT_DESCRIPTION,"保存已输入的试题信息!");
			putValue(LONG_DESCRIPTION,"保存已输入的试题信息");
			putValue(MNEMONIC_KEY,new Integer('S'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			SingleTestQuestionEntryFrame saveFrame=(SingleTestQuestionEntryFrame)desktop.getSelectedFrame();
			TestQuestionEntry question=saveFrame.getTestQuestionEntry();
			try{
				//if(!questionDatabase.singleQuestionFound(question.getID())){
				questionDatabase.deleteQusetion(question.getID());
				questionDatabase.insertQuestion(question);
				JOptionPane.showMessageDialog(desktop, "成功添加试题");
				/*}else{
					JOptionPane.showMessageDialog(desktop, "该试题已存在");
				}*/
				desktop.getSelectedFrame().dispose();
			}
			catch(TestException exception){
				JOptionPane.showMessageDialog(desktop, exception, "试题输入失败", JOptionPane.ERROR_MESSAGE);
				exception.printStackTrace();
			}
		}		
	}
	private class SearchAndUpdataAction extends AbstractAction{
		/** inner class defines an action that can locate the specify 
		 * id of question in the database .
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public SearchAndUpdataAction(){
			//inner method for implementing.
			putValue(NAME,"试题信息查询和修改");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/search.gif")));
			putValue(SHORT_DESCRIPTION,"试题信息查询和修改!");
			putValue(LONG_DESCRIPTION,"试题信息查询和修改");
			putValue(MNEMONIC_KEY,new Integer('U'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			String questionID=JOptionPane.showInputDialog(desktop, "请输入查询试题编号!");
			if(questionID!=null){
				try {
					DatabaseSQLCommand com=new DatabaseSQLCommand();
					if(com.singleQuestionFound(questionID)){							
						TestQuestionEntry question=com.searchQusetion(questionID);
						SingleTestQuestionEntryFrame update=creatSingleTestQuestionEntryFrame();
						update.setTestQuestionEntry(question);
						update.setVisible(true);
						desktop.add(update);					
					}else{
						JOptionPane.showMessageDialog(desktop, "没有此题信息");
					}
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}else{
				JOptionPane.showMessageDialog(desktop, "输入不能为空");
			}
		}		
	}
	private class DeleteAction extends AbstractAction{
		/** inner class defines an action that can delete the specify 
		 * id of question in the database .
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public DeleteAction(){
			//inner method for implementing.
			putValue(NAME,"试题删除");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/delete.gif")));
			putValue(SHORT_DESCRIPTION,"删除一条特定的试题记录!");
			putValue(LONG_DESCRIPTION,"删除一条特定的试题记录");
			putValue(MNEMONIC_KEY,new Integer('D'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			String questionID=JOptionPane.showInputDialog(desktop, "请输入删除试题编号!");
			if(questionID!=null){
				try {
					DatabaseSQLCommand com=new DatabaseSQLCommand();
					if(com.singleQuestionFound(questionID)){
						com.deleteQusetion(questionID);
						JOptionPane.showMessageDialog(desktop, "删除成功");
					}
					else{
						JOptionPane.showMessageDialog(desktop, "该试题不存在");
					}
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}				
			}else
			{
				JOptionPane.showMessageDialog(desktop, "输入不能为空");
			}
		}
	}
	private class CompoundTestAction extends AbstractAction{
		/** inner class defines an action that can provide users to take a exam 
		 * base on specify demands.
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public CompoundTestAction(){
			//inner method for implementing.
			putValue(NAME,"组合试卷考试");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/test.gif")));
			putValue(SHORT_DESCRIPTION,"组合试卷考试!");
			putValue(LONG_DESCRIPTION,"组合试卷考试");
			putValue(MNEMONIC_KEY,new Integer('T'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			try {
				int id=1;
				String type;
				//num=1;
				DatabaseSQLCommand database=new DatabaseSQLCommand();
				TestLogic logic=new TestLogic();
				TestChoice testQuestion=new TestChoice();	
				TestFrame test=new TestFrame(); 
				AnswerPane answer=new AnswerPane();
				//answer.num=1;
				desktop.add(answer);
				desktop.add(test);
				test.testArea.append("JAVA考试:"+"\n");
				for(int i=0;i<10;i++){
				id=testQuestion.idRandom(database.lengthCount());
				while(!database.QuestionFound(id))id++;		
				logic.setID(id);
				type=database.queryType(id);
				if(type.equals("s")){
					answer.singleItem();
				}else if(type.equals("t")){
					answer.trueItem();
				}else if(type.equals("b")){
					answer.blankItem();
				}
				test.setVisible(true);
				test.testArea.append("第"+num+"题:");
				num++;
				test.testArea.append(database.queryQuestion(id)+"\n");
				}
				test.setVisible(true);
				markAction.setEnabled(true);
			} catch (Exception exception) {
				// TODO Auto-generated catch block
				exception.printStackTrace();
			}
		}
	}	
	private class SingleTestAction extends AbstractAction{
		/** inner class defines an action that can provide users to take a exam 
		 * base on specify demands.
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public SingleTestAction(){
			//inner method for implementing.
			putValue(NAME,"单题考试/下一题");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/test.gif")));
			putValue(SHORT_DESCRIPTION,"单题考试!");
			putValue(LONG_DESCRIPTION,"单题考试");
			putValue(MNEMONIC_KEY,new Integer('T'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			try {
				int id=1;
				String type;
				DatabaseSQLCommand database=new DatabaseSQLCommand();
				TestLogic logic=new TestLogic();
				TestChoice testQuestion=new TestChoice();		
				id=testQuestion.idRandom(database.lengthCount());
				while(!database.QuestionFound(id))id++;
				TestFrame test=new TestFrame(); 
				logic.setID(id);
				AnswerPane answer=new AnswerPane();
				type=database.queryType(id);
				if(type.equals("s")){
					answer.singleItem();
				}else if(type.equals("t")){
					answer.trueItem();
				}else if(type.equals("b")){
					answer.blankItem();
				}
				desktop.add(answer);
				desktop.add(test);
				test.setVisible(true);
				test.testArea.append("JAVA考试:"+"\n");
				test.testArea.append("第"+num+"题:");
				num++;
				test.testArea.append(database.queryQuestion(id));
				test.setVisible(true);
				markAction.setEnabled(true);
			} catch (Exception exception) {
				// TODO Auto-generated catch block
				exception.printStackTrace();
			}
		}
	}	
	private class MarkAction extends AbstractAction{
		/** inner class defines an action that can provide users to
		 *  mark the current exam
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public MarkAction(){
			//inner method for implementing.
			putValue(NAME,"考试评分");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/test.gif")));
			putValue(SHORT_DESCRIPTION,"考试评分");
			putValue(LONG_DESCRIPTION,"考试评分");
			putValue(MNEMONIC_KEY,new Integer('T'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			try {
				TestLogic mark=new TestLogic();			
				JOptionPane.showMessageDialog(desktop, "当前考试得分是:"+mark.getMark());
				desktop.getSelectedFrame().dispose();
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}	
	private class HelpAction extends AbstractAction{
		/** inner class defines an action that can provide users to get help 
		 * base on specify demands.
		 */
		private static final long serialVersionUID = 1L;
		//set up action's id,difficulty,timelimited,content,answer and score.
		public HelpAction(){
			//inner method for implementing.
			putValue(NAME,"帮助");
			//putValue(SMALL_ICON,new ImageIcon(getClass().getResource("images/help.gif")));
			putValue(SHORT_DESCRIPTION,"帮助文档!");
			putValue(LONG_DESCRIPTION,"帮助文档");
			putValue(MNEMONIC_KEY,new Integer('H'));
		}
		//display window in which user can input information.
		public void actionPerformed(ActionEvent e){
			//create new internal window ~~
			HelpFrame help=new HelpFrame();
			TestLogic helpCommand=new TestLogic();
			help.setVisible(true);
			desktop.add(help);
			help.testArea.append(helpCommand.testInput("commandHelp.txt").toString());		
		}
	}			
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new OnlineTest();	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -