<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &作业管理模块&
 */
 
 if (!defined('IS_RUN')) die('Forbidden');
 
 $M_user = G_class('user');
 $M_ann=G_class('ann');
 $M_homework=G_class('homework');
 $c= _get('c','index');
 
 $T=$c=='index'?$do:$do.'_'.$c;
 
  //左侧菜单开始 --后面考虑转到模块入口文件
  $left_menu_html = G_class('menu') ->get_left_menu_html($arrgroup['menuid'],$do,$c);
 
 $Modname = '考试管理 - 学校管理';
 
switch ($c){
		
		case "index":
		
		$Modname = '作业列表 - '.$Modname;

			//获取作业分类
			$arrwork = $M_homework->read_worktype();
			//作业列表
			$bid =$_CO['userbid'];
			$homeworkarr=$M_homework->read_all($bid);
			foreach($homeworkarr as $key =>$item){
				$homework[]=$item;
				$type=$M_homework->read_worktype($item['type']);
				$homework[$key]['typename']=$type[0]['subjectname'];
				$item['typename']=$type[0]['subjectname'];
			}
			
			//分页每页显示数据量
			$listnum = '10';
			//当前页
			$pid=$_GET['p'];
			if(is_numeric($pid)&&$pid>0){
				$pid=(int)$pid;
			}else{
				$pid='1';
			}
			//链接地址
			$url = SITEURL . '?mod=school&do=work&c=index';
			$sum = count($homework);
			$pidf = $pid-1;
			$start = $pidf*$listnum;
			$end = $listnum;
			foreach($homework as $key=>$value){
				$array[] = $value;
			}
			$homework = array();
			$homework = array_slice($array, $start, $end);
			$pageinfo = grtpageno($url, $sum, $listnum, $pid);
			
			//获取参数验证代码
			$homework=fields_code($homework,'homeworkid');
		break;
		
		case "work_content":
			if($_GET['workid'] && is_numeric($_GET['workid'])){
				$workid = intval($_GET['workid']);
			}else{
				Note('非法参数');
				exit;
			}
			$content = $M_homework->get_work_info($workid);
			$no_temp = 1;
			require_once Template("work_content");
			break;
	}
	

 if($no_temp<0) require_once Template($T);

?>